Database Modelling: Relationships Flashcards

1
Q

What are the the relationship (cardinality) options between entities?

A
  1. One-to-many
  2. Many-to-many
  3. One-to-one
    OPTIONAL: 4. None-at-all
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the natural order of database design?

A
  1. Sketch out entities -> tables
  2. Define data type of entities -> columns
  3. Determine which columns are primary keys or if need to generate primary keys

NOTE: This is not always a linear process!

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

What is the natural order of database design?

A
  1. Sketch out entities -> tables
  2. Define data type of entities -> columns
  3. Determine which columns are primary keys or if need to generate primary keys

NOTE: This is not always a linear process!

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

What is the benefit of formaly specifying the relationships between entities in a DBMS?

A

This allows the DBMS itself to ensure that the relationship between entities is VALID AND MEANINGFUL

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

Do the data types between the primary key and foreign key need to be the same?

A

YES

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

Do the names of the columns of the primary and foreign key need to be the same?

A

NO

Foreign key column an have different name as long as the name has a meaning behind it which relates it to the primary key

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

Can the one in a one-to-many relationship have multiple one-to-many relationships?

A

YES

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

Can the one in a one-to-many relationship have multiple one-to-many relationships?

A

YES

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

When designing the schema of a database, how do we denote the primary key and foreign key in the boxes which represent tables?

A

Primary is denoted as PK

Foreign is denotes as FK

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

Why are one-to-one relationships unusual to build?

A

One-to-one relationships can often share the same key to denote that they share a one-to-one relationship HOWEVER this can then be combined into a single table which makes the one-to-one relationship pointless in most cases.

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

Can you link a many-to-many relationship directly?

A

No

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

How do you link a many-to-many relationship?

A

Using a junction/linking table which links the various many-to-many relationships between multiple primary keys between tables. These junction tables have non-unique foreign keys from both tables to allow for multiple links with the same keys.

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

How do you name a linking table?

A

Combine the names of the two tables in the many-to-many relationship

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

What is a referential constrant?

A

This is a rule that applies between tables where each table applies the rule as well as cross-referencing its data with other tables to ensure that other tables are also following this rule.

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

What is referential integrity?

A

This refers to when the data is valid and meaningful between ALL tables and columns within a database

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

What is a cascading delete? What does it maintain?

A

This is when the removal of a certain row in a table results in all linked rows in other tables to that specific row to also be deleted. This ensures the referential integrity is maintained between tables.

16
Q

What is cascading nullify?

A

This is where the deletion of data in a row will cause linked rows to return a null value in the column that is directly linked to the deleted data.

E.g. Deleting a customer ID resulting in the foreign key of this ID to be NULL in other tables.

17
Q

What is No Action?

A

This refers to when attempting to delete data in a row is refused as the data is required to maintain data integrity. This data cannot be deleted until the foreign key is assigned to a new ID.