Database relationships Flashcards
(13 cards)
What is a relationship in relational databases?
A relationship links two tables in a database using a field that exists in each of the tables.
Relationships are fundamental for organizing data in relational databases.
What must exist to create a relationship between two tables?
A common field must exist in both tables.
This common field often serves as a primary key in one table and a foreign key in another.
What is the primary key in a database?
The key field that uniquely identifies a record in a table.
It is essential for establishing relationships between tables.
What is a foreign key in a database?
A primary key from one table that is stored in another table to establish a relationship.
It helps maintain referential integrity between tables.
What are the different degrees of relationships in a database?
One to Many, One to One, Many to Many.
These categories help in modeling the relationships between entities.
What does a One to Many (1:M) relationship mean?
One record in one table relates to many records in another table.
Example: One manager oversees many employees.
What does a One to One (1:1) relationship mean?
One record in one table relates to one record in another table.
Example: One country has one capital city.
What does a Many to Many (M:N) relationship mean?
Many records in one table relate to many records in another table.
Example: Many students take many courses.
What is an Entity Relationship Diagram (ERD)?
A visual representation of the relationships between entities in a database.
ERDs are used to model the structure of a database.
Identify an example of a One to Many relationship.
1 Manager oversees many Employees.
This relationship shows how one entity can relate to multiple entities.
Identify an example of a One to One relationship.
1 Country has 1 Capital City.
This relationship indicates a unique pairing of entities.
Identify an example of a Many to Many relationship.
Many Students take many Courses.
This shows that multiple entities can relate to each other in various combinations.
What is the significance of the Pupil ID in the context of relationships?
It serves as both a primary key and a foreign key in different tables.
This allows for linking pupil data across multiple tables.