Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Explanation of the "Values" concept' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Explanation of the "Values" concept
Authored by: babbage on Feb 18, '05 05:44:22PM

Lots of things with computers deal with key/value pairs. The "key" is something you refer to, while the "value" or "values" is/are the thing/s that the key points to.

Keys are used to look up values. Each key should refer to only one value, though it can be a compound, plural, or collective value, as in this case with multiple home directories. A value, on the other hand, can be pointed to by multiple keys. Because of this, values generally can't be used to determine keys, but keys can always be used to determine a value.

Some examples would probably illustrate more clearly.

* A dictionary term is a key; the corresponding definition is a value. Multiple keys can have the same value (the keys "chair" and "seat" might both point to the value "thing you can sit on").

* A name in a phone book is a key; the number is a value.

* An item in a book's index, or a keyword in a search engine, can be thought of as keys. The pages they refer to are values. Multiple index items or search terms may point to the same page.

* The number in a product's bar code is a key; the information about that product in a database is a value. Different stores might assign different product IDs to the same item.

* Computer login systems are built around comparing key/value pairs: you enter your username & password pair (which together form a key), and a program turns it into gibberish (a value). This gibberish is then passed to another program, which sees if the gibberish matches a database record for your account. If the values match, you're pemitted to log in.

* Functions in algebra are a way to determine key/value relationships. When figuring out f(x) = y, x is the key, and f is the mechanism for looking up the value y. (If f behaves in a way similar to the definition above, where each input value x corresponds to a unique output value y, it is sometimes called a "hash function"; hash functions are the key to all password systems and a whole lot of other computer systems as well.)

Because these relationships come up so often in computers -- databases, for example, are basically just glorified ways of managing key/value sets -- a lot of programming languages support for lists of keys & values built in directly. In Perl, a variable that contains a collection of key/value pairs is a hash, while the same construct in Python is simply called a dictionary. With databases, including OSX's NetInfo configuration database, each item in the database -- each key -- has corresponding values that can be looked up by knowing that key.

Make sense?

---

--
DO NOT LEAVE IT IS NOT REAL



[ Reply to This | # ]