Professional Documents
Culture Documents
CSCE 2501 Fundamentals of Database Systems - Lec 4
CSCE 2501 Fundamentals of Database Systems - Lec 4
Outline
▪ RDM is based on a very simple and uniform data structure - the relation
▪ The relation resembles a table or a simple file
▪ Each relation has a set of attributes (column name) describing the entity type the
relation represents.
▪ The domain of an attribute is all the possible values that a given entity can draw its
actual value for the target attribute from
▪ Each domain has a data type which defines the types of the values in the domain for the attribute
CSCE 2501 - Fall 2021
Degree
Primary Key
The unique identifier for the relation / table. It can be either a single attribute
or a
collection of attributes that are unique for each entity / row in the table
CSCE 2501 - Fall 2021
Properties of Relations
Name Number
Middle Last
First
Name National ID
Gender
Employee Employee (National_ID, FirstName, MiddleName, LastName,
Address
Gender, Address, Salary, Birthdate)
Salary
Birthdate Composite attributes are split into their individual components
CSCE 2501 - Fall 2021
Multivalued attributes are split into a separate relation / entity with a primary key
consisting of the attribute itself and the primary key of the main entity
Name Number
Department (Name, Number)
Department Location DepartmentLocation(Number, Location)
Weak entities are represented as either a composite attribute in the owning relation or as
a separate relation with the primary key copied from the owning relation
Gender Birthdate
Dependent Dependent (National_ID, Name, Birthdate, Relationship,
Name
Gender)
Relationship
CSCE 2501 - Fall 2021
M N
Employee Works on Project
One-to-many relationships can be represented by including the primary key of the one
relation into the attributes of the many relation → Foreign Key
1 N
Department Controls Project
Foreign Key
CSCE 2501 - Fall 2021
Foreign Key
OR
Foreign Key
CSCE 2501 - Fall 2021
▪ Integrity constraints ensure that all the data stored in the database is accurate and
consistent
Primary Key
▪ Candidate Keys are the set of single attributes (or sets of attributes) K that can
uniquely identify every tuple in a given relation
▪ Primary key provides the basic mechanism for identifying a specific tuple in a
relation
CSCE 2501 - Fall 2021
No component of the primary key of any base relation is allowed to have a Null
value
▪ Following from the fact that the primary key is used to identify tuples in a relation, if
the primary key is allowed to have null values, the corresponding tuples are
unidentifiable
CSCE 2501 - Fall 2021
Foreign Keys
▪ Foreign Key is an attribute (or set of attributes) that are added to the relational
model to represent a relationship between two relations
▪ The values of the foreign key in a given relation are required to match the values of the primary
key of the associated relation in the represented relationship
▪ For non-null foreign key values, there should always be a matching value in the
primary key values in the target relation
▪ No tuple should reference another tuple that doesn’t exist in the target relation
CSCE 2501 - Fall 2021
Name National ID
Department
Gender N 1
Works for
Employee Locations
Address # Employees
1
Salary Hours
N Controls
1 M
Birthdate 1
supervise
Owns Works on N
N Name Number
N
PK
Department (Dept_No, Dept_Name, Manager_National_ID, Manager_Start_Date)
FK (Employee)
PK PK
DepartmentLocations (Dept_No, Location) Project (P_No, P_Name, Location, Dept_No)
FK (Department) FK (Department)
PK PK
WorksOn (National_ID, P_No, Hours) Dependent (National_ID, Name, Gender, BDate, Relationship)
FK (Employee) FK (Project) FK (Employee)