Database Modelling: Relationships Flashcards
What are the the relationship (cardinality) options between entities?
- One-to-many
- Many-to-many
- One-to-one
OPTIONAL: 4. None-at-all
What is the natural order of database design?
- Sketch out entities -> tables
- Define data type of entities -> columns
- Determine which columns are primary keys or if need to generate primary keys
NOTE: This is not always a linear process!
What is the natural order of database design?
- Sketch out entities -> tables
- Define data type of entities -> columns
- Determine which columns are primary keys or if need to generate primary keys
NOTE: This is not always a linear process!
What is the benefit of formaly specifying the relationships between entities in a DBMS?
This allows the DBMS itself to ensure that the relationship between entities is VALID AND MEANINGFUL
Do the data types between the primary key and foreign key need to be the same?
YES
Do the names of the columns of the primary and foreign key need to be the same?
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
Can the one in a one-to-many relationship have multiple one-to-many relationships?
YES
Can the one in a one-to-many relationship have multiple one-to-many relationships?
YES
When designing the schema of a database, how do we denote the primary key and foreign key in the boxes which represent tables?
Primary is denoted as PK
Foreign is denotes as FK
Why are one-to-one relationships unusual to build?
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.
Can you link a many-to-many relationship directly?
No
How do you link a many-to-many relationship?
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 do you name a linking table?
Combine the names of the two tables in the many-to-many relationship
What is a referential constrant?
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.
What is referential integrity?
This refers to when the data is valid and meaningful between ALL tables and columns within a database