d1 - relational database and subqueries and joins and sequalize Flashcards

1
Q

what does RDD stand for?

A

relational database design. With RDD, data is organized into tables and all types of data access are carried out via controlled transactions.

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

what are the stages of relational database design?

A
  1. Define the purpose/entities of the relational DB
  2. Identify primary keys
  3. Establish table relationships
  4. Apply normalization rules
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What’s an entity for RDD?

A

tables

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

What’s a record for RDD?

A

rows

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

What is a one-to-one table relationship?

A

one record is associated with one record in another table

least common table relationship

ex. 1 mug associated with 1 description

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

What’s a one-to-many table relationship?

A

one record is associated with many records in another table

ex. each user can have multiple orders

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

What’s a many-to-many table relationship?

A

joining many records with many tables. Normally you’d create a third joined table.

ex. each user has multiple orders. each order contains an order_id and a product id (in addition to the id of the order)

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

What’s normalization for RDD?

A

it’s the process of optimizing the database structure so that it’s not redundant or confusing

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

What are the rules for normalization?

A
  1. first normal form
  2. second normal form
  3. third normal form
  4. Boyce-Codd normal form
  5. fifth normal form
  • first 3 are widely used in practice
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the first normal form rules?

A
  • eliminate repeating groups in indiv tables
  • create a sep table for each set of related data
  • identify each set of related data with a primary key
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the second normal form rules?

A
  • create separate tables for sets of values that apply to multiple records
  • relate these tables with a foreign key
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the third normal form rules?

A
  • eliminate fields that do not depend on the table’s key
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the different types of join operations?

A
  1. inner join
  2. left join
  3. right join
  4. full outer join
  5. self-join
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What’s inner join?

A

returns a result set container rows in the left table that match rows in the right table.

ex. table A matches rows with table B (left side matches right side)

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

What’s a left join?

A

Returns a result set containing all rows from the left table with the matching rows from the right table. If there is no match, the right side will have null values.

ex. table A matches rows with table B, BUT if there’s no match the right side has null values

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

What’s a right join?

A

Returns a result set containing all rows from the right table with matching rows from the left table. If there is no match, the left side will have null values.

ex. table B matches rows with table A, BUT if there’s no match the left side has null values

17
Q

What’s a full outer join?

A

Returns a result set containing all rows from both the left and right tables, with the matching rows from both sides where available. If there is no match, the missing side contains null values.

ex. table A matches rows with table B. if no match, missing side contains null values

18
Q

What’s a self-join?

A

A self-join is a query in which a table is joined to itself. Self-joins are useful for comparing values in a column of rows within the same table.

ex. table A is joined to itself

19
Q

What’s a subquery?

A

a SELECT statement nested inside another SELECT statement

20
Q

When to use join operation vs. subqueiries?

A

JOIN is best when you want to combine rows from one or more tables based on a match condition.

Subqueries work well when you’re returning a single value

When returning multiple rows you could use either.

21
Q

What’s sequelize?

A

a JS library. It’s an example of object relational mapping (ORM).

ORMs allow JS programmers to fetch and store data in a SQL database using JS functions instead of writing SQL code.