Revision - Data Modeling Flashcards

(10 cards)

1
Q

What is the difference strategy of modeling data for a Relational DB (SQL) and NoSQL Document DB?

A
  1. SQL : Focuses on Normalizing data (manage data in tables to avoid data duplication)
  2. No SQL : Focuses on Denormalizing data (manage data into single, self-contained JSON documents for faster reads)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does Embedding data mean in NoSQL database?

A

Treating entities as self-contained items by placing related child data directly inside the parent JSON document

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

List out 1 example of Embedding data into a JSON document in NoSQL database?

A

Putting an array of contact details inside a Person document

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

List out 3 Scenarios where we SHOULD use Embeded Data

A
  1. The embedded data does not grow without bound (it has a limited size).
  2. The data doesn’t change frequently
  3. There are one-to-few relationships between entities (A user can register 2 number plates at the Parking System)
  4. There are contained relationships between entities (If Data B exists because of Data A, is should be contained in Data A’s JSON Document)

When not to emded is just the opposite of this

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the major drawback of Embedding an array that has “unbounded growth”

embedding millions of comments directly inside a single Blog Post document

A

The JSON document will grow infinitely large, making the mobile app slow and expensive to operate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does “Referencing” data mean in a NoSQL database?

A

Keeping related entities in separate documents and using an ID to connect them

Similar to a Foreign Key (FK) in SQL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

List out 3 scenarios that we SHOULD use Reference data

A
  1. Related data changes frequently
  2. References data could be unbounded
  3. Representing one-to-many relationships
  4. Representing many-to-many relationships
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a “Hybrid Data Model” in NoSQL?

A

Mixing both embedding and referencing

a Book document might reference the authorId to keep the full profile separate, but it embeds the authorName and thumbnailUrl so the app doesn’t have to make a second database query just to display the book list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In a Parking App, a user is limited to registering 3 car number plates. Should you use Embedding or Referencing? Why?

A

Embedding. This is a One-to-Few relationship. Since the data is small and limited, embedding allows the Flutter app to retrieve the user profile and all plates in a single, fast, and cost-effective database read.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

In SQL, we use “JOIN” to combine tables at runtime. Why is this considered a disadvantage for mobile apps compared to NoSQL Embedding?

A

Performance and Latency. JOINS require the database to do work at the moment you ask for data. In NoSQL, the data is already “composed” (pre-joined) in one document, making it much faster to send to a mobile device.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly