What is a 'Key' in computer science? Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Origins of the term “distributed hash table”What is the meaning of this pseudo-code function?What is the definition of Computer Science, and what is the Science within Computer Science?What exactly is computer science?What is determinism in computer science?How do you express the theorem statement about unsuccessful search on average-case for unsuccessful searches in hashing with quantifiers?What Exactly Does the Term “Key” Mean with Regards to a Hash Table?Why must a Primary Index be sparse?What is standardization in computer science?How hash-table and hash-map are different?

How to begin with a paragraph in latex

Determinant of a matrix with 2 equal rows

Is Bran literally the world's memory?

Lazy Loading a Bioinformatic SAM record

What *exactly* is electrical current, voltage, and resistance?

Protagonist's race is hidden - should I reveal it?

What is the ongoing value of the Kanban board to the developers as opposed to management

All ASCII characters with a given bit count

Israeli soda type drink

Deciphering death certificate writing

What's parked in Mil Moscow helicopter plant?

How did Elite on the NES work?

Marquee sign letters

Could a cockatrice have parasitic embryos?

What happened to Viserion in Season 7?

What helicopter has the most rotor blades?

Is there a possibility to generate a list dynamically in Latex?

Why is water being consumed when my shutoff valve is closed?

Processing ADC conversion result: DMA vs Processor Registers

Why these surprising proportionalities of integrals involving odd zeta values?

Has a Nobel Peace laureate ever been accused of war crimes?

Specify the range of GridLines

Will I have to go through TSA security when I return to the US after preclearance?

Putting Ant-Man on house arrest



What is a 'Key' in computer science?



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Origins of the term “distributed hash table”What is the meaning of this pseudo-code function?What is the definition of Computer Science, and what is the Science within Computer Science?What exactly is computer science?What is determinism in computer science?How do you express the theorem statement about unsuccessful search on average-case for unsuccessful searches in hashing with quantifiers?What Exactly Does the Term “Key” Mean with Regards to a Hash Table?Why must a Primary Index be sparse?What is standardization in computer science?How hash-table and hash-map are different?










3












$begingroup$


I'm a bit confused on what exactly the meaning of a 'key' is in computer science. I understand key-value pairs, primary keys, etc... But I can't find a definition of what the term 'key' means by itself.



As far as I can tell it just means a piece of data. In CLRS, data associated with tree nodes are referred to as 'keys'. Data to search a hash table is called a 'key'. Is this what a 'key' is?










share|cite|improve this question







New contributor




TheMax is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$







  • 1




    $begingroup$
    There is not one specific technical definition. The use of the word is usually inspired by its normal, English definition, e.g. merriam-webster.com/dictionary/key Or rather I should say "definitions". In general, your expectation should be that there isn't a unifying technical definition for common English words that are used in multiple contexts even within a single field of study.
    $endgroup$
    – Derek Elkins
    1 min ago















3












$begingroup$


I'm a bit confused on what exactly the meaning of a 'key' is in computer science. I understand key-value pairs, primary keys, etc... But I can't find a definition of what the term 'key' means by itself.



As far as I can tell it just means a piece of data. In CLRS, data associated with tree nodes are referred to as 'keys'. Data to search a hash table is called a 'key'. Is this what a 'key' is?










share|cite|improve this question







New contributor




TheMax is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$







  • 1




    $begingroup$
    There is not one specific technical definition. The use of the word is usually inspired by its normal, English definition, e.g. merriam-webster.com/dictionary/key Or rather I should say "definitions". In general, your expectation should be that there isn't a unifying technical definition for common English words that are used in multiple contexts even within a single field of study.
    $endgroup$
    – Derek Elkins
    1 min ago













3












3








3


1



$begingroup$


I'm a bit confused on what exactly the meaning of a 'key' is in computer science. I understand key-value pairs, primary keys, etc... But I can't find a definition of what the term 'key' means by itself.



As far as I can tell it just means a piece of data. In CLRS, data associated with tree nodes are referred to as 'keys'. Data to search a hash table is called a 'key'. Is this what a 'key' is?










share|cite|improve this question







New contributor




TheMax is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




I'm a bit confused on what exactly the meaning of a 'key' is in computer science. I understand key-value pairs, primary keys, etc... But I can't find a definition of what the term 'key' means by itself.



As far as I can tell it just means a piece of data. In CLRS, data associated with tree nodes are referred to as 'keys'. Data to search a hash table is called a 'key'. Is this what a 'key' is?







terminology






share|cite|improve this question







New contributor




TheMax is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|cite|improve this question







New contributor




TheMax is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|cite|improve this question




share|cite|improve this question






New contributor




TheMax is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 hours ago









TheMaxTheMax

192




192




New contributor




TheMax is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





TheMax is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






TheMax is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 1




    $begingroup$
    There is not one specific technical definition. The use of the word is usually inspired by its normal, English definition, e.g. merriam-webster.com/dictionary/key Or rather I should say "definitions". In general, your expectation should be that there isn't a unifying technical definition for common English words that are used in multiple contexts even within a single field of study.
    $endgroup$
    – Derek Elkins
    1 min ago












  • 1




    $begingroup$
    There is not one specific technical definition. The use of the word is usually inspired by its normal, English definition, e.g. merriam-webster.com/dictionary/key Or rather I should say "definitions". In general, your expectation should be that there isn't a unifying technical definition for common English words that are used in multiple contexts even within a single field of study.
    $endgroup$
    – Derek Elkins
    1 min ago







1




1




$begingroup$
There is not one specific technical definition. The use of the word is usually inspired by its normal, English definition, e.g. merriam-webster.com/dictionary/key Or rather I should say "definitions". In general, your expectation should be that there isn't a unifying technical definition for common English words that are used in multiple contexts even within a single field of study.
$endgroup$
– Derek Elkins
1 min ago




$begingroup$
There is not one specific technical definition. The use of the word is usually inspired by its normal, English definition, e.g. merriam-webster.com/dictionary/key Or rather I should say "definitions". In general, your expectation should be that there isn't a unifying technical definition for common English words that are used in multiple contexts even within a single field of study.
$endgroup$
– Derek Elkins
1 min ago










2 Answers
2






active

oldest

votes


















5












$begingroup$

A key in the context of data structures (such as in the book CLRS) is a value (often an integer) that is used to identify a certain component of a data-structure. Often, keys determine how the underlying data is stored or manipulated. For example, in binary search trees we have that for every node, the key of that node is larger than the keys in the left sub-tree and smaller than those in the right subtree. This property makes it easier to search for a given key (or determine there is no node with such a key).



In practice, our 'actual' data is often not a key, but something larger and more relevant that a single number. This data is called satellite data and can be mostly ignored when dealing with manipulations on data structures, as long as the satellite data moves whenever the key gets moved (otherwise, you lose track of your data).




The concept of a key is similar in the context of databases, but there it is often required that a key is unique. A primary key has to be unique, for example. This requirement is often nessecary in the context of data-structures, but is sometimes made for simplicity.



In cryptography, a key usually refers to an (often secret, but not always!) parameter that is needed to encrypt or decrypt with a given en- or decryption algorithm. The keys used to encrypt and decrypt have to be 'related' (in symmetric cryptography, the need to be the same) for the process to encryption or decryption to be successful.






share|cite|improve this answer











$endgroup$












  • $begingroup$
    And in cryptography?
    $endgroup$
    – jpmc26
    38 mins ago










  • $begingroup$
    What is the difference between satellite data and keys then? From what I understand, satellite data is data organized by the data structure that is not part of the actual structure. So can I say a keys and satellite data are both data in the structure, but keys are part of the structure and satellite data is not?
    $endgroup$
    – TheMax
    35 mins ago










  • $begingroup$
    @jpmc26 Added, thanks for mentioning it.
    $endgroup$
    – Discrete lizard
    31 mins ago










  • $begingroup$
    @TheMax In a way, yes. The precise content of the satellite data is irrelevant for the operations on the data-structure (but likely relevant for the application using the data structure). This decoupling of key and data makes it easier for to design efficient data-structures.
    $endgroup$
    – Discrete lizard
    29 mins ago


















2












$begingroup$

In the most general sense, a key is a piece of information required to retrieve some data. However, this meaning plays out differently depending on exactly what situation you're dealing with.



In the contexts you mention, a key is a unique identifier for the complete data used to retrieve it from some location in the structure. Each key is associated with only one item, so it can be used to find a particular set of data. The data structure will usually be organized in such a way that finding the key is much more efficient than a linear search through all of the data. Sometimes the key is actually part of the data and stored along with it (like primary keys in the database); other times, it is segregated from the data itself (like in a hash map). The data structure will also often perform extra processing on the key (and only the key) to support its efficient searching algorithm (such as in a hash map, the key is converted into a hash code, or a database will index the primary keys using a B-tree).



In cryptography, a key is used in a sense more akin to physical keys used on locks. They're pieces of data required to obtain the original from the encrypted data (to "unlock" the data, so to speak).






share|cite|improve this answer








New contributor




jpmc26 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$












  • $begingroup$
    To prevent possible confusion: in the book CLRS, keys are usually not considered to be unique, as they don't have to be for many data structures.
    $endgroup$
    – Discrete lizard
    1 min ago











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "419"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






TheMax is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcs.stackexchange.com%2fquestions%2f107439%2fwhat-is-a-key-in-computer-science%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









5












$begingroup$

A key in the context of data structures (such as in the book CLRS) is a value (often an integer) that is used to identify a certain component of a data-structure. Often, keys determine how the underlying data is stored or manipulated. For example, in binary search trees we have that for every node, the key of that node is larger than the keys in the left sub-tree and smaller than those in the right subtree. This property makes it easier to search for a given key (or determine there is no node with such a key).



In practice, our 'actual' data is often not a key, but something larger and more relevant that a single number. This data is called satellite data and can be mostly ignored when dealing with manipulations on data structures, as long as the satellite data moves whenever the key gets moved (otherwise, you lose track of your data).




The concept of a key is similar in the context of databases, but there it is often required that a key is unique. A primary key has to be unique, for example. This requirement is often nessecary in the context of data-structures, but is sometimes made for simplicity.



In cryptography, a key usually refers to an (often secret, but not always!) parameter that is needed to encrypt or decrypt with a given en- or decryption algorithm. The keys used to encrypt and decrypt have to be 'related' (in symmetric cryptography, the need to be the same) for the process to encryption or decryption to be successful.






share|cite|improve this answer











$endgroup$












  • $begingroup$
    And in cryptography?
    $endgroup$
    – jpmc26
    38 mins ago










  • $begingroup$
    What is the difference between satellite data and keys then? From what I understand, satellite data is data organized by the data structure that is not part of the actual structure. So can I say a keys and satellite data are both data in the structure, but keys are part of the structure and satellite data is not?
    $endgroup$
    – TheMax
    35 mins ago










  • $begingroup$
    @jpmc26 Added, thanks for mentioning it.
    $endgroup$
    – Discrete lizard
    31 mins ago










  • $begingroup$
    @TheMax In a way, yes. The precise content of the satellite data is irrelevant for the operations on the data-structure (but likely relevant for the application using the data structure). This decoupling of key and data makes it easier for to design efficient data-structures.
    $endgroup$
    – Discrete lizard
    29 mins ago















5












$begingroup$

A key in the context of data structures (such as in the book CLRS) is a value (often an integer) that is used to identify a certain component of a data-structure. Often, keys determine how the underlying data is stored or manipulated. For example, in binary search trees we have that for every node, the key of that node is larger than the keys in the left sub-tree and smaller than those in the right subtree. This property makes it easier to search for a given key (or determine there is no node with such a key).



In practice, our 'actual' data is often not a key, but something larger and more relevant that a single number. This data is called satellite data and can be mostly ignored when dealing with manipulations on data structures, as long as the satellite data moves whenever the key gets moved (otherwise, you lose track of your data).




The concept of a key is similar in the context of databases, but there it is often required that a key is unique. A primary key has to be unique, for example. This requirement is often nessecary in the context of data-structures, but is sometimes made for simplicity.



In cryptography, a key usually refers to an (often secret, but not always!) parameter that is needed to encrypt or decrypt with a given en- or decryption algorithm. The keys used to encrypt and decrypt have to be 'related' (in symmetric cryptography, the need to be the same) for the process to encryption or decryption to be successful.






share|cite|improve this answer











$endgroup$












  • $begingroup$
    And in cryptography?
    $endgroup$
    – jpmc26
    38 mins ago










  • $begingroup$
    What is the difference between satellite data and keys then? From what I understand, satellite data is data organized by the data structure that is not part of the actual structure. So can I say a keys and satellite data are both data in the structure, but keys are part of the structure and satellite data is not?
    $endgroup$
    – TheMax
    35 mins ago










  • $begingroup$
    @jpmc26 Added, thanks for mentioning it.
    $endgroup$
    – Discrete lizard
    31 mins ago










  • $begingroup$
    @TheMax In a way, yes. The precise content of the satellite data is irrelevant for the operations on the data-structure (but likely relevant for the application using the data structure). This decoupling of key and data makes it easier for to design efficient data-structures.
    $endgroup$
    – Discrete lizard
    29 mins ago













5












5








5





$begingroup$

A key in the context of data structures (such as in the book CLRS) is a value (often an integer) that is used to identify a certain component of a data-structure. Often, keys determine how the underlying data is stored or manipulated. For example, in binary search trees we have that for every node, the key of that node is larger than the keys in the left sub-tree and smaller than those in the right subtree. This property makes it easier to search for a given key (or determine there is no node with such a key).



In practice, our 'actual' data is often not a key, but something larger and more relevant that a single number. This data is called satellite data and can be mostly ignored when dealing with manipulations on data structures, as long as the satellite data moves whenever the key gets moved (otherwise, you lose track of your data).




The concept of a key is similar in the context of databases, but there it is often required that a key is unique. A primary key has to be unique, for example. This requirement is often nessecary in the context of data-structures, but is sometimes made for simplicity.



In cryptography, a key usually refers to an (often secret, but not always!) parameter that is needed to encrypt or decrypt with a given en- or decryption algorithm. The keys used to encrypt and decrypt have to be 'related' (in symmetric cryptography, the need to be the same) for the process to encryption or decryption to be successful.






share|cite|improve this answer











$endgroup$



A key in the context of data structures (such as in the book CLRS) is a value (often an integer) that is used to identify a certain component of a data-structure. Often, keys determine how the underlying data is stored or manipulated. For example, in binary search trees we have that for every node, the key of that node is larger than the keys in the left sub-tree and smaller than those in the right subtree. This property makes it easier to search for a given key (or determine there is no node with such a key).



In practice, our 'actual' data is often not a key, but something larger and more relevant that a single number. This data is called satellite data and can be mostly ignored when dealing with manipulations on data structures, as long as the satellite data moves whenever the key gets moved (otherwise, you lose track of your data).




The concept of a key is similar in the context of databases, but there it is often required that a key is unique. A primary key has to be unique, for example. This requirement is often nessecary in the context of data-structures, but is sometimes made for simplicity.



In cryptography, a key usually refers to an (often secret, but not always!) parameter that is needed to encrypt or decrypt with a given en- or decryption algorithm. The keys used to encrypt and decrypt have to be 'related' (in symmetric cryptography, the need to be the same) for the process to encryption or decryption to be successful.







share|cite|improve this answer














share|cite|improve this answer



share|cite|improve this answer








edited 16 secs ago

























answered 1 hour ago









Discrete lizardDiscrete lizard

4,68311538




4,68311538











  • $begingroup$
    And in cryptography?
    $endgroup$
    – jpmc26
    38 mins ago










  • $begingroup$
    What is the difference between satellite data and keys then? From what I understand, satellite data is data organized by the data structure that is not part of the actual structure. So can I say a keys and satellite data are both data in the structure, but keys are part of the structure and satellite data is not?
    $endgroup$
    – TheMax
    35 mins ago










  • $begingroup$
    @jpmc26 Added, thanks for mentioning it.
    $endgroup$
    – Discrete lizard
    31 mins ago










  • $begingroup$
    @TheMax In a way, yes. The precise content of the satellite data is irrelevant for the operations on the data-structure (but likely relevant for the application using the data structure). This decoupling of key and data makes it easier for to design efficient data-structures.
    $endgroup$
    – Discrete lizard
    29 mins ago
















  • $begingroup$
    And in cryptography?
    $endgroup$
    – jpmc26
    38 mins ago










  • $begingroup$
    What is the difference between satellite data and keys then? From what I understand, satellite data is data organized by the data structure that is not part of the actual structure. So can I say a keys and satellite data are both data in the structure, but keys are part of the structure and satellite data is not?
    $endgroup$
    – TheMax
    35 mins ago










  • $begingroup$
    @jpmc26 Added, thanks for mentioning it.
    $endgroup$
    – Discrete lizard
    31 mins ago










  • $begingroup$
    @TheMax In a way, yes. The precise content of the satellite data is irrelevant for the operations on the data-structure (but likely relevant for the application using the data structure). This decoupling of key and data makes it easier for to design efficient data-structures.
    $endgroup$
    – Discrete lizard
    29 mins ago















$begingroup$
And in cryptography?
$endgroup$
– jpmc26
38 mins ago




$begingroup$
And in cryptography?
$endgroup$
– jpmc26
38 mins ago












$begingroup$
What is the difference between satellite data and keys then? From what I understand, satellite data is data organized by the data structure that is not part of the actual structure. So can I say a keys and satellite data are both data in the structure, but keys are part of the structure and satellite data is not?
$endgroup$
– TheMax
35 mins ago




$begingroup$
What is the difference between satellite data and keys then? From what I understand, satellite data is data organized by the data structure that is not part of the actual structure. So can I say a keys and satellite data are both data in the structure, but keys are part of the structure and satellite data is not?
$endgroup$
– TheMax
35 mins ago












$begingroup$
@jpmc26 Added, thanks for mentioning it.
$endgroup$
– Discrete lizard
31 mins ago




$begingroup$
@jpmc26 Added, thanks for mentioning it.
$endgroup$
– Discrete lizard
31 mins ago












$begingroup$
@TheMax In a way, yes. The precise content of the satellite data is irrelevant for the operations on the data-structure (but likely relevant for the application using the data structure). This decoupling of key and data makes it easier for to design efficient data-structures.
$endgroup$
– Discrete lizard
29 mins ago




$begingroup$
@TheMax In a way, yes. The precise content of the satellite data is irrelevant for the operations on the data-structure (but likely relevant for the application using the data structure). This decoupling of key and data makes it easier for to design efficient data-structures.
$endgroup$
– Discrete lizard
29 mins ago











2












$begingroup$

In the most general sense, a key is a piece of information required to retrieve some data. However, this meaning plays out differently depending on exactly what situation you're dealing with.



In the contexts you mention, a key is a unique identifier for the complete data used to retrieve it from some location in the structure. Each key is associated with only one item, so it can be used to find a particular set of data. The data structure will usually be organized in such a way that finding the key is much more efficient than a linear search through all of the data. Sometimes the key is actually part of the data and stored along with it (like primary keys in the database); other times, it is segregated from the data itself (like in a hash map). The data structure will also often perform extra processing on the key (and only the key) to support its efficient searching algorithm (such as in a hash map, the key is converted into a hash code, or a database will index the primary keys using a B-tree).



In cryptography, a key is used in a sense more akin to physical keys used on locks. They're pieces of data required to obtain the original from the encrypted data (to "unlock" the data, so to speak).






share|cite|improve this answer








New contributor




jpmc26 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$












  • $begingroup$
    To prevent possible confusion: in the book CLRS, keys are usually not considered to be unique, as they don't have to be for many data structures.
    $endgroup$
    – Discrete lizard
    1 min ago















2












$begingroup$

In the most general sense, a key is a piece of information required to retrieve some data. However, this meaning plays out differently depending on exactly what situation you're dealing with.



In the contexts you mention, a key is a unique identifier for the complete data used to retrieve it from some location in the structure. Each key is associated with only one item, so it can be used to find a particular set of data. The data structure will usually be organized in such a way that finding the key is much more efficient than a linear search through all of the data. Sometimes the key is actually part of the data and stored along with it (like primary keys in the database); other times, it is segregated from the data itself (like in a hash map). The data structure will also often perform extra processing on the key (and only the key) to support its efficient searching algorithm (such as in a hash map, the key is converted into a hash code, or a database will index the primary keys using a B-tree).



In cryptography, a key is used in a sense more akin to physical keys used on locks. They're pieces of data required to obtain the original from the encrypted data (to "unlock" the data, so to speak).






share|cite|improve this answer








New contributor




jpmc26 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$












  • $begingroup$
    To prevent possible confusion: in the book CLRS, keys are usually not considered to be unique, as they don't have to be for many data structures.
    $endgroup$
    – Discrete lizard
    1 min ago













2












2








2





$begingroup$

In the most general sense, a key is a piece of information required to retrieve some data. However, this meaning plays out differently depending on exactly what situation you're dealing with.



In the contexts you mention, a key is a unique identifier for the complete data used to retrieve it from some location in the structure. Each key is associated with only one item, so it can be used to find a particular set of data. The data structure will usually be organized in such a way that finding the key is much more efficient than a linear search through all of the data. Sometimes the key is actually part of the data and stored along with it (like primary keys in the database); other times, it is segregated from the data itself (like in a hash map). The data structure will also often perform extra processing on the key (and only the key) to support its efficient searching algorithm (such as in a hash map, the key is converted into a hash code, or a database will index the primary keys using a B-tree).



In cryptography, a key is used in a sense more akin to physical keys used on locks. They're pieces of data required to obtain the original from the encrypted data (to "unlock" the data, so to speak).






share|cite|improve this answer








New contributor




jpmc26 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$



In the most general sense, a key is a piece of information required to retrieve some data. However, this meaning plays out differently depending on exactly what situation you're dealing with.



In the contexts you mention, a key is a unique identifier for the complete data used to retrieve it from some location in the structure. Each key is associated with only one item, so it can be used to find a particular set of data. The data structure will usually be organized in such a way that finding the key is much more efficient than a linear search through all of the data. Sometimes the key is actually part of the data and stored along with it (like primary keys in the database); other times, it is segregated from the data itself (like in a hash map). The data structure will also often perform extra processing on the key (and only the key) to support its efficient searching algorithm (such as in a hash map, the key is converted into a hash code, or a database will index the primary keys using a B-tree).



In cryptography, a key is used in a sense more akin to physical keys used on locks. They're pieces of data required to obtain the original from the encrypted data (to "unlock" the data, so to speak).







share|cite|improve this answer








New contributor




jpmc26 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|cite|improve this answer



share|cite|improve this answer






New contributor




jpmc26 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered 25 mins ago









jpmc26jpmc26

1234




1234




New contributor




jpmc26 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





jpmc26 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






jpmc26 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • $begingroup$
    To prevent possible confusion: in the book CLRS, keys are usually not considered to be unique, as they don't have to be for many data structures.
    $endgroup$
    – Discrete lizard
    1 min ago
















  • $begingroup$
    To prevent possible confusion: in the book CLRS, keys are usually not considered to be unique, as they don't have to be for many data structures.
    $endgroup$
    – Discrete lizard
    1 min ago















$begingroup$
To prevent possible confusion: in the book CLRS, keys are usually not considered to be unique, as they don't have to be for many data structures.
$endgroup$
– Discrete lizard
1 min ago




$begingroup$
To prevent possible confusion: in the book CLRS, keys are usually not considered to be unique, as they don't have to be for many data structures.
$endgroup$
– Discrete lizard
1 min ago










TheMax is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















TheMax is a new contributor. Be nice, and check out our Code of Conduct.












TheMax is a new contributor. Be nice, and check out our Code of Conduct.











TheMax is a new contributor. Be nice, and check out our Code of Conduct.














Thanks for contributing an answer to Computer Science Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcs.stackexchange.com%2fquestions%2f107439%2fwhat-is-a-key-in-computer-science%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown