SlideShare a Scribd company logo
1 of 23
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 field is its
         value, the data that
         is being identified and
         stored.
key-value pairs


          A field name,
          together with the
          data entered into
          that field, is a
          key-value
          pair.
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 record
         will have a field
         called "city".
city: “Buffalo”


        Every record contains
        the key "city", and
        in one particular
        record its value
        might be "Buffalo". It's
        pretty straightforward.
city: “Toronto”




In another record in the same Contacts
database, 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 no-no.

       Data should be only be
       stored in the value.
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:
     it is similar to its neighbor
     in structure (the keys),
     but different in content
     (the values).
good questions


Consistency makes it easy to ask the database some
good questions. Often we are looking for some
particular value, and the key helps us find it.
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.
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 other
records, another city is listed (or no city is
recorded).
SELECT * from Contacts
WHERE city == "Buffalo"
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.
SELECT DISTINCT city
from Contacts
where does Jim Smith live?

"Dallas"

Tell the database management
system to go to Jim Smith's record
and return the value of the city field.
SELECT city WHERE
person == “Jim Smith”
when did Jim Smith live in Dallas?

   Can't say. But maybe if we had included
   more key-value pairs in each record, this
   query could have been answered.

   beginning : "1998"
   ending : "2005"
SELECT beginning WHERE
person == "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 answer this query. A useful design might
 include these keys:

    work
    hometown
    spouse
good design

When designing a database, we should consider
what questions we will want answered. Then we
can make sure we capture the data needed to
answer those questions.

Database design starts with key-value pairs.
(the)   Little Data Project
        littledataproject.org

More Related Content

Featured

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Key-Value Pairs

  • 1. key-value pairs (the) Little Data Project littledataproject.org
  • 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. key-value pairs A field name, together with the data entered into that field, is a key-value pair.
  • 4. a unique identifier A key is a unique identifier, and a value is the actual data that is being identified.
  • 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. city: “Buffalo” Every record contains the key "city", and in one particular record its value might be "Buffalo". It's pretty straightforward.
  • 7. city: “Toronto” In another record in the same Contacts database, the city might be "Toronto”. Same key, different value.
  • 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. age 19: “yes” And what if: age 19 = "no” … ? How old is the person then?
  • 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. good questions Consistency makes it easy to ask the database some good questions. Often we are looking for some particular value, and the key helps us find it.
  • 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. 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 other records, another city is listed (or no city is recorded).
  • 14. SELECT * from Contacts WHERE city == "Buffalo"
  • 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.
  • 17. where does Jim Smith live? "Dallas" Tell the database management system to go to Jim Smith's record and return the value of the city field.
  • 18. SELECT city WHERE person == “Jim Smith”
  • 19. when did Jim Smith live in Dallas? Can't 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. SELECT beginning WHERE person == "Jim Smith" & city == "Dallas" SELECT ending WHERE person == "Jim Smith" & city == "Dallas"
  • 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. good design When designing a database, we should consider what questions we will want answered. Then we can make sure we capture the data needed to answer those questions. Database design starts with key-value pairs.
  • 23. (the) Little Data Project littledataproject.org