Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
key-value pairs (the)   Little Data Project     littledataproject.org
key-value pairs         A key is a field name,         an attribute, an         identifier. The content         of that fi...
key-value pairs          A field name,          together with the          data entered into          that field, is a    ...
a unique identifier       A key is a unique identifier,       and a value is the actual       data that is being identified.
show me an example         For instance, in a         Contacts database         (i.e., an address         book), each reco...
city: “Buffalo”        Every record contains        the key "city", and        in one particular        record its value  ...
city: “Toronto”In another record in the same Contactsdatabase, the city might be "Toronto”.Same key, different value.
age 19: “yes”       Now the pair above is       not well designed. The       key itself holds some       data, which is a ...
age 19: “yes”       And what if:       age 19 = "no” … ?       How old is the person       then?
consistency     In a relational     database, each record     includes the same keys.     Each record is consistent:     i...
good questionsConsistency makes it easy to ask the database somegood questions. Often we are looking for someparticular va...
good questions  In the following examples, each  record includes a field with the key  "city", and each record has a value...
who lives in Buffalo?"George Hanna", "Lisa Durante","Carl Young""Buffalo" is the value listed in the field named"city" in ...
SELECT * from ContactsWHERE city == "Buffalo"
what cities are listed in the db?  "Buffalo", "Hamilton",  "Dallas", "Toronto"  Across all the records in the database,  t...
SELECT DISTINCT cityfrom Contacts
where does Jim Smith live?"Dallas"Tell the database managementsystem to go to Jim Smiths recordand return the value of the...
SELECT city WHEREperson == “Jim Smith”
when did Jim Smith live in Dallas?   Cant say. But maybe if we had included   more key-value pairs in each record, this   ...
SELECT beginning WHEREperson == "Jim Smith" &city == "Dallas"SELECT ending WHERE person== "Jim Smith" & city =="Dallas"
why did Jim Smith live in Dallas? This database is just an address book. It does not contain the kind of data needed to an...
good designWhen designing a database, we should considerwhat questions we will want answered. Then wecan make sure we capt...
(the)   Little Data Project        littledataproject.org
Upcoming SlideShare
Loading in …5
×

Key-Value Pairs

8,864 views

Published on

  • Login to see the comments

Key-Value Pairs

  1. 1. key-value pairs (the) Little Data Project littledataproject.org
  2. 2. key-value pairs A key is a field name, an attribute, an identifier. The content of that field is its value, the data that is being identified and stored.
  3. 3. key-value pairs A field name, together with the data entered into that field, is a key-value pair.
  4. 4. a unique identifier A key is a unique identifier, and a value is the actual data that is being identified.
  5. 5. show me an example For instance, in a Contacts database (i.e., an address book), each record will have a field called "city".
  6. 6. city: “Buffalo” Every record contains the key "city", and in one particular record its value might be "Buffalo". Its pretty straightforward.
  7. 7. city: “Toronto”In another record in the same Contactsdatabase, the city might be "Toronto”.Same key, different value.
  8. 8. age 19: “yes” Now the pair above is not well designed. The key itself holds some data, which is a no-no. Data should be only be stored in the value.
  9. 9. age 19: “yes” And what if: age 19 = "no” … ? How old is the person then?
  10. 10. consistency In a relational database, each record includes the same keys. Each record is consistent: it is similar to its neighbor in structure (the keys), but different in content (the values).
  11. 11. good questionsConsistency makes it easy to ask the database somegood questions. Often we are looking for someparticular value, and the key helps us find it.
  12. 12. good questions In the following examples, each record includes a field with the key "city", and each record has a value entered into that field. There are all sorts of things we can ask (query) the database.
  13. 13. who lives in Buffalo?"George Hanna", "Lisa Durante","Carl Young""Buffalo" is the value listed in the field named"city" in each of these three records. In otherrecords, another city is listed (or no city isrecorded).
  14. 14. SELECT * from ContactsWHERE city == "Buffalo"
  15. 15. what cities are listed in the db? "Buffalo", "Hamilton", "Dallas", "Toronto" Across all the records in the database, these city names are mentioned in the field named "city". This database holds twenty records. "Buffalo" is listed in three different records.
  16. 16. SELECT DISTINCT cityfrom Contacts
  17. 17. where does Jim Smith live?"Dallas"Tell the database managementsystem to go to Jim Smiths recordand return the value of the city field.
  18. 18. SELECT city WHEREperson == “Jim Smith”
  19. 19. when did Jim Smith live in Dallas? Cant say. But maybe if we had included more key-value pairs in each record, this query could have been answered. beginning : "1998" ending : "2005"
  20. 20. SELECT beginning WHEREperson == "Jim Smith" &city == "Dallas"SELECT ending WHERE person== "Jim Smith" & city =="Dallas"
  21. 21. why did Jim Smith live in Dallas? This database is just an address book. It does not contain the kind of data needed to answer this query. A useful design might include these keys: work hometown spouse
  22. 22. good designWhen designing a database, we should considerwhat questions we will want answered. Then wecan make sure we capture the data needed toanswer those questions.Database design starts with key-value pairs.
  23. 23. (the) Little Data Project littledataproject.org

×