Semistructured Data
October 19, 2023
Data 101, Fall 2023 @ UC Berkeley
Lisa Yan https://fa23.data101.org/
1
LECTURE 17
Join at slido.com�#707070
ⓘ
Click Present with Slido or install our Chrome extension to display joining instructions for participants while presenting.
Translate into a Relational Schema
Translate into a Relational Schema
Normalization
Functional Dependencies
Semi-Structured Data
JSON
Transforming b/t Rectangular Data & JSON
XML
Why Semi-Structured Data?
NoSQL
[Extra] Key-Value Stores
3
[from last time]
Lecture 17, Data 101 Fall 2023
[Review] From ER Diagrams to Relational Schema
Recall: The ER diagram is a part in the design process we can use to�build a relational schema.
Next, the design process is three-step:
4
Three key principles:
#707070
[Review] Relationship to Relation: Many-to-one
5
ER Design → Relational Schema:
If the relationship is many-one or one-one, it may make sense to combine representations,�since all columns are foreign keys or attributes of the relation.
Instead of:� Product(price,name,category)� Makes(Product.name,category,� startyear,Company.name)
Company(name,stockprice)
Combine to:
Product(name,category,
startdate,companyname)
Company(name, stockprice)
name
category
price
Product
Company
makes
stockprice
name
startyear
typo fixed post-�lecture
at most one
many
#707070
[cont.] Part 2. Relationship to Relation: Many-to-one
6
If the relationship is many-one or one-one, it may make sense to combine representations,�since all columns are foreign keys or attributes of the relation.
Instead of:� Product(price,name,category)� Makes(Product.name,category,� startdate,Company.name)� Company(name,stockprice)
Combine to:
Product(name,category,
startdate,companyname)
Company(name, stockprice)
name
category
price
Product
Company
makes
stockprice
name
startyear
name | category | price |
gizmo | gadgets | 19.99 |
kphone | phone | 200.00 |
Product.name | category | startyear | Company.name |
gizmo | gadgets | 1963 | gizmoWorks |
name | category | price | startyear | companyname |
gizmo | gadgets | 19.99 | 1963 | gizmoWorks |
kphone | phone | 200.00 | NULL | NULL |
typo fixed post-�lecture
at most one
many
#707070
Exercise: ER Diagram on Movies
7
🤔
title
director
rdate
Movies
Studios
name
addr
cost
(release date)
releases
Presidents
runs
name
salary
How can we reduce redundancy of one-to-one and many-to-one?
Format: A schema in the resulting less redundant relational schema, e.g.,
Movies(title, director)
#707070
How can we reduce redundancy of one-to-one and many-to-one?
Format: A schema in the resulting less redundant relational schema, e.g., Movies(title, director)
ⓘ
Click Present with Slido or install our Chrome extension to activate this poll while presenting.
Exercise: One possible solution
9
title
director
rdate
Movies
Studios
name
addr
cost
(release date)
releases
Presidents
runs
name
salary
Many-to-one,�movie must have studio
Movies(title, director,� cost, rdate, studio_name)
#707070
Exercise: One possible solution, continued
10
title
director
rdate
Movies
Studios
name
addr
cost
(release date)
releases
Presidents
runs
name
salary
Movies(title, director,� cost, rdate, studio_name)
One-to-one, president must have studio; studio has at most one president
Many-to-one,�movie must have studio
Studios(name, addr,� pres_name, pres_salary)
#707070
Exercise
11
Why not go all the way and have all the information in one table? We risk massive redundancy! (because of the many-one)
Studios
name
addr
Movies(title, director,� cost, rdate, studio_name)
One-to-one, president must have studio; studio has at most one president
Many-to-one,�movie must have studio
Studios(name, addr,� pres_name, pres_salary)
There are many ways to redesign relational schema; we’ve just shown you some examples here. Next up: a preview of a generalized process.
title
director
rdate
Movies
cost
(release date)
releases
Presidents
runs
name
salary
#707070
Normalization
Translate into a Relational Schema
Normalization
Functional Dependencies
Semi-Structured Data
JSON
Transforming b/t Rectangular Data & JSON
XML
Why Semi-Structured Data?
NoSQL
[Extra] Key-Value Stores
12
Lecture 17, Data 101 Fall 2023
Two final pieces: Functional Dependencies and Normalization
Our current process:
⚠️ We are not quite done!
Two final intuitive pieces:
For now, let’s consider an example where our current process is insufficient. We’ll then do an intuitive overview of normalization/functional dependencies…but we’ll skip the details.
13
#707070
Individual with several phones
Why might this be a bad design?
The issue:
14
Address | SSN | phone number |
10 Green | 123-456-789 | (201) 233-1456 |
10 Green | 123-456-789 | (201) 123-3439 |
431 Purple | 987-654-321 | (145) 241-2131 |
431 Purple | 987-654-321 | (312) 123-1287 |
… | … | … |
#707070
Individual with several phones: A Normalized Design
This design was achieved through normalization.
Why might this be a better design?
15
Address | SSN |
10 Green | 123-456-789 |
431 Purple | 987-654-321 |
… | … |
SSN | phone number |
123-456-789 | (201) 233-1456 |
123-456-789 | (201) 123-3439 |
987-654-321 | (145) 241-2131 |
987-654-321 | (312) 123-1287 |
… | … |
How do we recover the original relation? Use a natural join!
Note: Minimizing redundancy is just one objective; there are others, but we won’t cover them here.
#707070
Individual with several phones: A Normalized Design
How do we perform normalization?
This design was achieved through normalization.
Why might this be a better design?
Tradeoffs of normalization:
16
Address | SSN |
10 Green | 123-456-789 |
431 Purple | 987-654-321 |
… | … |
SSN | phone number |
123-456-789 | (201) 233-1456 |
123-456-789 | (201) 123-3439 |
987-654-321 | (145) 241-2131 |
987-654-321 | (312) 123-1287 |
… | … |
How do we recover the original relation? Use a natural join!
#707070
Functional Dependencies
Translate into a Relational Schema
Normalization
Functional Dependencies
Semi-Structured Data
Document Store: JSON
Transforming b/t Rectangular Data & JSON
XML
Why Semi-Structured Data?
NoSQL
[Extra] Key-Value Stores
17
This will not be covered in lecture! It will be covered in Discussion 8.
See Lecture 16 for preview.
Lecture 17, Data 101 Fall 2023
Semi-Structured Data
Translate into a Relational Schema
Normalization
Functional Dependencies
Semi-Structured Data
JSON
Transforming b/t Rectangular Data & JSON
XML
Why Semi-Structured Data?
NoSQL
[Extra] Key-Value Stores
18
Lecture 17, Data 101 Fall 2023
The advent of the Data Lake
19
#707070
Structured Data Models
So far:
All of these data models are still rectangular, i.e., structured.
20
#707070
Structured Data Models
So far:
All of these data models are still rectangular, i.e., structured.
21
Structured, rectangular assumptions:
1. There is a fixed set of attributes.
2. Attributes are atomic.
3. Attributes can’t be nested.
#707070
From Structured to Semi-Structured Data
Semi-structured data is a data representation or data model that is less “rigid” than structured or rectangular data.
Removes all three of the following assumptions:
1. There is a fixed set of attributes. → Flexible schema.
2. Attributes are atomic. → Attributes can be multivalued.
3. Attributes can’t be nested. → Attributes can be nested.
Semi-structured data is exemplified by a few popular formats:
22
#707070
Is Semi-Structured New?
Semi-structured data actually existed prior to structured data!
In modern situations, semi-structured data works well as a data exchange format.
Increasingly, some DBMSes support (or even only support) semi-structured data models:
23
#707070
JSON
Translate into a Relational Schema
Normalization
Functional Dependencies
Semi-Structured Data
JSON
Transforming b/t Rectangular Data & JSON
XML
Why Semi-Structured Data?
NoSQL
[Extra] Key-Value Stores
24
Lecture 17, Data 101 Fall 2023
JSON: JavaScript Object Notation
JSON is a textual representation of complex data types.
25
JSON is widely used for transmitting data between applications and storing complex data.
[
{
"title":"Benchmarking Spreadsheet Systems",
"link": "https://people.eecs.berkeley.edu/~adityagp/papers/spreadsheet_bench.pdf",
"authors": "Sajjadur Rahman, Kelly Mack, Mangesh Bendre, Ruilin Zhang, Karrie Karahalios, Aditya Parameswaran",
"conf":"SIGMOD Int'l Conf. on Management of Data",
"location": "Portland, USA",
"date": "June 2020",
...
},
{
"title":"ShapeSearch: A Flexible and Efficient System for Shape-based Exploration of Trendlines",
"link": "https://arxiv.org/abs/1811.07977",
"authors":"Tarique Siddiqui, Zesheng Wang, Paul Luh, Karrie Karahalios, Aditya Parameswaran",
"status":"Unpublished Manuscript",
"date": "June 2020",
"price": 7.95,
...
},
"this is just a string",
...
]
#707070
JSON Types and Values
Values can be Primitives, Objects, or Arrays.
26
[
{
"title":"Benchmarking Spreadsheet Systems",
"link": "https://people.eecs.berkeley.edu/~adityagp/papers/spreadsheet_bench.pdf",
"authors": "Sajjadur Rahman, Kelly Mack, Mangesh Bendre, Ruilin Zhang, Karrie Karahalios, Aditya Parameswaran",
"conf":"SIGMOD Int'l Conf. on Management of Data",
"location": "Portland, USA",
"date": "June 2020",
...
},
{
"title":"ShapeSearch: A Flexible and Efficient System for Shape-based Exploration of Trendlines",
"link": "https://arxiv.org/abs/1811.07977",
"authors":"Tarique Siddiqui, Zesheng Wang, Paul Luh, Karrie Karahalios, Aditya Parameswaran",
"status":"Unpublished Manuscript",
"date": "June 2020",
"price": 7.95,
...
},
"this is just a string",
...
]
Primitive: number, string, boolean, null
Object: collection of key-value pairs.
{"key1": value1,� "key2": value2, ... }
Array: ordered list of values.
[val1, val2, val3, ...]
#707070
JSON Semantics are a Tree!
27
person
Mary
name
address
name
address
street
no
city
Maple
345
SF
John
Thai
phone
23456
0
1
{"person":
[
{
"name": "Mary",
"address":
{
"street":"Maple",
"no":345,
"city": "SF"
}
},
{
"name": "John",
"address": "Thailand",
"phone":2345678
}
]
}
element 0
element 1
In JSON, arrays are ordered.
#707070
Back to the Papers example
Why use JSON for representing paper data?
1. Flexibility in set of attributes
2. Self-describing
28
3. JSON can be easily parsed within JavaScript�for rendering
4. Very small data! Likely <100 papers for even a full faculty
[
{
"title":"Benchmarking Spreadsheet Systems",
"link": "https://people.eecs.berkeley.edu/~adityagp/papers/spreadsheet_bench.pdf",
"authors": "Sajjadur Rahman, Kelly Mack, Mangesh Bendre, Ruilin Zhang, Karrie Karahalios, Aditya Parameswaran",
"conf":"SIGMOD Int'l Conf. on Management of Data",
"location": "Portland, USA",
"date": "June 2020",
...
},
{
"title":"ShapeSearch: A Flexible and Efficient System for Shape-based Exploration of Trendlines",
"link": "https://arxiv.org/abs/1811.07977",
"authors":"Tarique Siddiqui, Zesheng Wang, Paul Luh, Karrie Karahalios, Aditya Parameswaran",
"status":"Unpublished Manuscript",
"date": "June 2020",
"price": 7.95,
...
},
"this is just a string",
...
]
#707070
How do we represent Papers in the Relational Model?
Option 1: All applicable attributes in one schema:�(title, link, authors, conf, location, date, status)
Option 2: Split into two relations based on un/published� published(title,link,authors,date,conf,location)� unpublished(title,link,authors,date,status)
Option 3: Split into three relations via normalization
29
[
{
"title":"Benchmarking Spreadsheet Systems",
"link": "https://people.eecs.berkeley.edu/~adityagp/papers/spreadsheet_bench.pdf",
"authors": "Sajjadur Rahman, Kelly Mack, Mangesh Bendre, Ruilin Zhang, Karrie Karahalios, Aditya Parameswaran",
"conf":"SIGMOD Int'l Conf. on Management of Data",
"location": "Portland, USA",
"date": "June 2020",
...
},
{
"title":"ShapeSearch: A Flexible and Efficient System for Shape-based Exploration of Trendlines",
"link": "https://arxiv.org/abs/1811.07977",
"authors":"Tarique Siddiqui, Zesheng Wang, Paul Luh, Karrie Karahalios, Aditya Parameswaran",
"status":"Unpublished Manuscript",
"date": "June 2020",
"price": 7.95,
...
},
"this is just a string",
...
]
All three options are not ideal for this use case. Nevertheless, sometimes we need to transform JSON data to rectangular data, and vice versa. Let’s do this!
#707070
Transforming between Rectangular Data and JSON
Translate into a Relational Schema
Normalization
Functional Dependencies
Semi-Structured Data
JSON
Transforming b/t Rectangular Data & JSON
XML
Why Semi-Structured Data?
NoSQL
[Extra] Key-Value Stores
30
Lecture 17, Data 101 Fall 2023
Transform Rectangular Data → JSON
Rectangular data can be represented by a balanced tree, which then translates to a JSON.
31
Person
name | phone |
John | 3634 |
Aliyah | 6343 |
Dirk | 6363 |
{“person”: [�{“name”: “John”, “phone”:3634},�{“name”: “Aliyah”, “phone”:6343},
{“name”: “Dirk”, “phone”:6383}�] }
name
name
name
phone
phone
phone
“John”
3634
“Aliyah”
“Dirk”
6343
6363
person
#707070
Transform Rectangular Data → JSON
Rectangular data can be represented by a balanced tree, which then translates to a JSON.
May inline (i.e., nest) multiple relations if related.
32
Person
{“Person”:
[{"name": "John",
"phone":3646,�"Orders":[�{"date":2002,"product":"Gizmo"},�{“date”:2004,"product":"Gadget"}�]
},
{"name": "Aliyah",�"phone":6343,�"Orders":[
{"date":2002,"product":"Gadget"}�]
}
]
}
name | phone |
John | 3634 |
Aliyah | 6343 |
personName | date | product |
John | 2002 | Gizmo |
John | 2004 | Gadget |
Aliyah | 2002 | Gadget |
Person
Product
orders
name
phone
date
name
Orders
#707070
Many-many relationships are much more difficult!
33
Person
name | phone |
John | 3634 |
Aliyah | 6343 |
personName | date | product |
John | 2002 | Gizmo |
John | 2004 | Gadget |
Aliyah | 2002 | Gadget |
Orders
Person
Product
orders
name
phone
date
name
name | price |
Gizmo | 19.99 |
Phone | 29.99 |
Gadget | 9.99 |
Product
price
Note: We now have a separate Product relation because price is a non-index Product attribute that would be redundant to append to Orders.
#707070
Many-many relationships are much more difficult!
Several options for the JSON file. Here’s a few:
34
Person
name | phone |
John | 3634 |
Aliyah | 6343 |
personName | date | product |
John | 2002 | Gizmo |
John | 2004 | Gadget |
Aliyah | 2002 | Gadget |
Orders
name | price |
Gizmo | 19.99 |
Phone | 29.99 |
Gadget | 9.99 |
Product
#707070
Many-many relationships are much more difficult!
Several options for the JSON file. Here’s a few:
35
Person
name | phone |
John | 3634 |
Aliyah | 6343 |
personName | date | product |
John | 2002 | Gizmo |
John | 2004 | Gadget |
Aliyah | 2002 | Gadget |
Orders
name | price |
Gizmo | 19.99 |
Phone | 29.99 |
Gadget | 9.99 |
Product
🤔
Suppose we convert the relational database using Option 2. How many times will the 9.99 price be present in the resulting JSON?
A. 0
B. 1
C. 2
D. 3
E. 4
F. Something� else
#707070
Suppose we convert the relational database using Option 2. How many times will the 9.99 price be present in the resulting JSON?
ⓘ
Click Present with Slido or install our Chrome extension to activate this poll while presenting.
Many-many relationships are much more difficult!
Several options for the JSON file. Here’s a few:
37
Person
name | phone |
John | 3634 |
Aliyah | 6343 |
personName | date | product |
John | 2002 | Gizmo |
John | 2004 | Gadget |
Aliyah | 2002 | Gadget |
Orders
name | price |
Gizmo | 19.99 |
Phone | 29.99 |
Gadget | 9.99 |
Product
Suppose we convert the relational database using Option 2. How many times will the 9.99 price be present in the resulting JSON?
{"Person":
[{"name": "John",
"phone":3646,�"Orders":[�{"date":2002,"Product":
{"name": "Gizmo",
"price": "19.99},
}]
], …
}
Price value is repeated as many times as it is ordered! (here: 2x)
JSON does not (natively) support joins.
Subsequently, redundancy is a necessary product of denormalization due to nesting..
#707070
Transform JSON → Rectangular Data
This transformation process is much more complicated and requires high-touch design.
Straightforward:�Fixing the unfixed schema.�Missing attributes → NULL values.
38
{"person":� [{"name":"Or", "phone":1234},� {"name":"Aliyah"}]�}
name | phone |
Or | 1234 |
Aliyah | NULL |
#707070
Transform JSON → Rectangular Data
This transformation process is much more complicated and requires high-touch design.
Straightforward:�Fixing the unfixed schema.�Missing attributes → NULL values.
More complicated: Converting multivalues to atomic values.
39
{"person":� [{"name":"Or", "phone":1234},� {"name":"Noor",� "phone": "23-4565"}]�}
Text wrangling/�canonicalization needed!
#707070
Transform JSON → Rectangular Data
This transformation process is much more complicated and requires high-touch design.
Straightforward:�Fixing the unfixed schema.�Missing attributes → NULL values.
More complicated: Converting multivalues to atomic values.
More complicated: Converting nested values to atomic values.
40
name | phone | |
Noor | 2345 | 3456 |
| | |
name | phone1 | phone2 |
Noor | 2345 | 3456 |
name | phone |
Noor | 2345 |
Noor | 3456 |
❌ Impossible (because of fixed schema)
Most phone2’s are likely NULL!
Index on phones will break!
Indexes on names will break!
{"person":� [{"name":"Or", "phone":1234},� {"name":"Noor",� "phone": [2345, 3456]}]�}
#707070
Transform JSON → Rectangular Data
This transformation process is much more complicated and requires high-touch design.
Straightforward:�Fixing the unfixed schema.�Missing attributes → NULL values.
More complicated: Converting multivalues to atomic values.
More complicated: Converting nested values to atomic values.
41
name | phone | |
Noor | 2345 | 3456 |
| | |
name | phone1 | phone2 |
Noor | 2345 | 3456 |
name | phone |
Noor | 2345 |
Noor | 3456 |
❌ Impossible (because of fixed schema)
Most phone2’s are likely NULL!
Index on phones will break!
Indexes on names will break!
{"person":� [{"name":"Or", "phone":1234},� {"name":"Noor",� "phone": [2345, 3456]}]�}
#707070
Transform JSON → Rectangular Data
This transformation process is much more complicated and requires high-touch design.
Straightforward:�Fixing the unfixed schema.�Missing attributes → NULL values.
More complicated: Converting multivalues to atomic values.
More complicated: Converting nested values to atomic values.
Even more difficult representations:
42
{"person":� [{"name":"Or", "phone":1234},� {"name": {"first": "Noor",
"last": "Cohen"},� "phone": [2345, 3456]}]�}
#707070
Exercise: Transform JSON → Rectangular Data
{
"ID": "22222",
"name": {
"firstname": "Albert",
"lastname": "Einstein"
},
"deptname": "Physics",
"children": [
{
"firstname": "Hans",
"lastname": "Einstein"
},
{
"firstname": "Eduard",
"lastname": "Einstein"
}
]
}
1. Denormalized representation:� (ID, firstname, lastname, deptname,� childfn, childln)
2. Normalized representation:� (ID, firstname, lastname, deptname)� (ID, childfn, childln)
43
🤔
What are disadvantages of the following rectangular representations?
A. Repeated information for each child
B. Unnecessary joins
C. Something else
#707070
What are disadvantages of the following rectangular representations?
ⓘ
Click Present with Slido or install our Chrome extension to activate this poll while presenting.
Exercise: Transform JSON → Rectangular Data
1. Denormalized representation:� (ID, firstname, lastname, deptname,� childfn, childln)
2. Normalized representation:� (ID, firstname, lastname, deptname)� (ID, childfn, childln)
{
"ID": "22222",
"name": {
"firstname": "Albert",
"lastname": "Einstein"
},
"deptname": "Physics",
"children": [
{
"firstname": "Hans",
"lastname": "Einstein"
},
{
"firstname": "Eduard",
"lastname": "Einstein"
}
]
}
45
What are disadvantages of the following rectangular representations?
A. Repeated information for each child
B. Unnecessary joins
#707070
JSON: Pros and Cons
Cons:
Pros:
46
#707070
Aside: XML
Translate into a Relational Schema
Normalization
Functional Dependencies
Semi-Structured Data
JSON
Transforming b/t Rectangular Data & JSON
XML
Why Semi-Structured Data?
NoSQL
[Extra] Key-Value Stores
47
Lecture 17, Data 101 Fall 2023
XML: eXtensible Markup Language
XML is an older semi-structured data format (from the late 90s).
48
<purchase order>
<identifier> P-101 </identifier>
<purchaser>
<name> Wile E. Coyote </name>
<address> Route 66, Mesa Flats, Arizona 86047, USA</address>
</purchaser>
<supplier>
<name> Acme Supplies </name>
<address> 1 Broadway, New York, NY, USA </address>
</supplier>
<itemlist>
<item>
<identifier> RS1 </identifier>
<description> Atom powered rocket sled </description>
<quantity> 2 </quantity>
<price> 199.95 </price>
</item>
<item>
...
</item>
</itemlist>
<total cost>
429.85
</total cost>
</purchase order>
2013
A precursor to JSON!
#707070
XML: eXtensible Markup Language
XML is an older semi-structured data format (from the late 90s).
A lot of effort went into developing XML formalism and query languages
49
<purchase order>
<identifier> P-101 </identifier>
<purchaser>
<name> Wile E. Coyote </name>
<address> Route 66, Mesa Flats, Arizona 86047, USA</address>
</purchaser>
<supplier>
<name> Acme Supplies </name>
<address> 1 Broadway, New York, NY, USA </address>
</supplier>
<itemlist>
<item>
<identifier> RS1 </identifier>
<description> Atom powered rocket sled </description>
<quantity> 2 </quantity>
<price> 199.95 </price>
</item>
<item>
...
</item>
</itemlist>
<total cost>
429.85
</total cost>
</purchase order>
#707070
Document Stores
Translate into a Relational Schema
Normalization
Functional Dependencies
Semi-Structured Data
JSON
Transforming b/t Rectangular Data & JSON
XML
Why Semi-Structured Data?
NoSQL
[Extra] Key-Value Stores
50
[for next time]
Lecture 17, Data 101 Fall 2023
Why not Semi-structured Data?
While semi-structured data models existed prior to structured data, it is clear that relational databases “won” in the long term.
51
Several reasons for why nested relations fell out of DBMS vogue:
See:
However, many data transfer lake/lakehouse applications means that we will have to work with semi-structured data somehow!
#707070
Document Stores are JSON-Native Data Systems
Document Stores are data systems that primarily operate on JSON.
52
MongoDB (more next time):
Document stores support a set of operations:
#707070
When Should We Use Document Stores?
It makes sense to use document stores if our data is inherently denormalized, and
53
#707070
When Should We Use Document Stores?
Compelling example: All Facebook User Profiles in a single JSON document.
It makes sense to use document stores if our data is inherently denormalized, and
54
Compelling example 2: Transfer/share/data across media
#707070
NoSQL and Scaling
Translate into a Relational Schema
Normalization
Functional Dependencies
Semi-Structured Data
JSON
Transforming b/t Rectangular Data & JSON
XML
Why Semi-Structured Data?
NoSQL
[Extra] Key-Value Stores
55
[for next time]
Lecture 17, Data 101 Fall 2023
NoSQL: Motivation
NoSQL is a hip name for document stores.
56
NoSQL as a phrase emerged in late 2000s (but again, it’s existed since the 1960s with XML systems).
#707070
NoSQL: Scalability
57
#707070
NoSQL systems are scalable
Without the rectangular / structured data constraints:
58
With NoSQL, we don’t perform joins or ensure strong consistency.
Instead, with NoSQL we only have to guarantee eventual consistency.
#707070
Two approaches to scaling: Partitioning and Replication
Replication
Partitioning (aka Sharding)
59
#707070
Scalability is HARD in Relational Models!
Relational models are difficult to replicate/partition.
60
Relational databases are required to maintain consistency!
#707070
SQL or NoSQL?
1. The goal is to build a service for tens of millions of Amazon shoppers, which will store each shopper’s past 100 viewed products. The stored data is shopper specific, and should be used for targeted product advertisements towards that shopper. It’s fine if this data is a little out-of-date. What kind of database should be used?
2. The goal is to build a service at PayPal that can allow users to apply for loans through the app. The service needs a database to store loan applications. In addition to the loan amount, the application also needs information regarding the user’s current balance and prior transaction history. What kind of database should be used?
61
🤔
A. SQL
B. NoSQL
#707070
SQL or NoSQL?
ⓘ
Click Present with Slido or install our Chrome extension to activate this poll while presenting.
SQL vs NoSQL?
1. The goal is to build a service for tens of millions of Amazon shoppers, which will store each shopper’s past 100 viewed products. The stored data is shopper specific, and should be used for targeted product advertisements towards that shopper. It’s fine if this data is a little out-of-date. What kind of database should be used?
2. The goal is to build a service at PayPal that can allow users to apply for loans through the app. The service needs a database to store loan applications. In addition to the loan amount, the application also needs information regarding the user’s current balance and prior transaction history. What kind of database should be used?
63
A. SQL
B. NoSQL
#707070
[Extra] Key-Value Stores
Translate into a Relational Schema
Normalization
Functional Dependencies
Semi-Structured Data
JSON
Transforming b/t Rectangular Data & JSON
XML
Why Semi-Structured Data?
NoSQL
[Extra] Key-Value Stores
64
[extra material]
Lecture 17, Data 101 Fall 2023
Data Models for Semi-structured Data
65
#707070
Key-Value Stores
66
#707070
Key-Value Stores Scaling
67
#707070
Example
How would you represent the Flights data as key, value pairs?
68
Flights(fid, date, carrier_id, flight_num, origin, dest, ...) Carriers(cid, name)
#707070