4) Relational Model Flashcards
(50 cards)
What is the key idea of the relational model in database systems?
Everything in the database is represented as relations (tables)
Relations can be thought of as tables where rows represent entities and columns represent attributes.
What does a relation represent in a database?
A relation is essentially an entity type, represented as a table
Rows in a relation represent individual entities, while columns represent their attributes.
What is a row in a relation also known as?
A tuple
A tuple represents one record, such as an employee or person.
What are the core parts of a relation (table)?
- Row
- Header
- Domain
Each part has its specific role in defining the structure of the relation.
What is the role of the header in a relation?
The header consists of attribute names (column names)
Each attribute has a type for the values under it, such as int or string.
Define ‘domain’ in the context of a relation.
The domain is the set of allowed values for an attribute
It includes both data type and valid values.
What does it mean for a domain to be atomic?
It must represent just one single value, not a list or structure
Examples of atomic values include 25, ‘Alice’, and ‘Economics’.
What is an example of a non-atomic value?
[‘Reading’, ’Swimming’]
Non-atomic values cannot be used in the domain of an attribute.
What is the relationship between an attribute and its domain?
Each attribute has a domain equal to the set of valid values for that attribute
For example, the domain for the Age attribute might be integers between 16 and 80.
Provide an example of a relation schema.
HOBBY(PersonName, Age, HobbyName)
Here, dom(PersonName) = Names shows the domain for the PersonName attribute.
What does dom(SSN) represent in the STUDENT relation?
Social-security-numbers
This indicates the domain of the SSN attribute in the STUDENT relation.
What is the structure of the STUDENT table?
Intension - STUDENT(Name, SSN, Age)
The table captures student information with attributes such as Name, SSN, and Age.
What does the Extension of the STUDENT table represent?
Extension - {<“Alice”, “123-45-6789”, 22>, <“Bob”, “987-65-4321”, null>}
This represents the real data stored in the table at a given moment.
Define the relation schema for HOBBY.
HOBBY(PersonName: FamilyName, Age: integer, HobbyName: Hobbies)
FamilyName and Hobbies are sets of possible options.
What is the shorter version of the HOBBY relation schema?
HOBBY(PersonName, Age, HobbyName)
This version includes just the attributes for simplicity.
What does a relation consist of?
A relation is a set of tuples
Each row in the relation corresponds to a tuple, and all tuples must be unique.
What is a super key?
A super key is any set of attributes in a table that can uniquely identify each row (tuple)
No two tuples can have the same values for the super key.
Give an example of a super key in the STUDENT table.
{SSN}, {Name, SSN}, {Name, SSN, Age}
All of these can uniquely identify each student.
What is a candidate key?
A candidate key is a minimal super key
It uniquely identifies each tuple and cannot have any unnecessary attributes.
What is the candidate key for the STUDENT table?
{SSN}
This is the minimal super key that maintains uniqueness.
What does the term ‘key’ refer to in this context?
Key = candidate key
A candidate key can be chosen as the primary key.
What is a primary key?
The primary key is the candidate key that is selected to identify tuples (rows) in the relation (table)
It serves as the main identifier for records in a table.
What is a foreign key?
An attribute (or set of attributes) in one relation that references the primary key of another relation
It establishes a link between two tables.
What are the conditions for a foreign key?
- Same Domain
- Matching Values
Foreign key attributes must have the same data type as the primary key and must either match or be NULL.