Database Management Systems: Relational Data Model Year II 2024/25
Database Management Systems: Relational Data Model Year II 2024/25
Database Management Systems: Relational Data Model Year II 2024/25
Systems
Relational data model
Year II
2024/25
Data model
A data model is an integrated collection of concepts for describing
data, relationships between data, and constraints on the data used by
an organization.
A data model attempts to represent the data requirements of the
organization, or the part of the organization, that you wish to model.
A data model can be thought of as comprising three components:
a structural part, consisting of a set of rules that define how the
database is to be constructed;
a manipulative part, defining the types of operations (transactions) that
are allowed on the data (this includes the operations that are used for
updating or retrieving data and for changing the structure of the
database);
possibly a set of integrity rules, which ensures that the data is accurate.
The purpose of a data model is to represent data and to make the data
understandable.
Terminology
The relational model is based on the
mathematical concept of a relation, which is
physically represented as a table.
Relation – It refers to a table with rows and
columns.
Attribute – This is a named column of a relation.
Domain – The set of allowable values for one or
more attributes.
Tuple – This is a record of a relation.
Relational database – This refers to a collection
of normalised tables.
Terminology cont…
Degree - Refers to the number of attributes
in a relation.
Cardinality – refers to the number of tuples
in a relation.
An instance of a database – refers to the
current state of the database.
Terminology Cont …
Examples of attribute domains
Alternative terminologies for a relational model
Properties of relational tables
A relational table has the following properties:
The table has a name that is distinct from all other tables
in the database.
Each cell of the table contains exactly one value.
Each column has a distinct name.
The values of a column are all from the same domain.
The order of columns has no significance. In other words,
provided a column name is moved along with the column
values, we can interchange columns.
Each record is distinct; there are no duplicate records.
The order of records has no significance, theoretically.
(However, in practice, the order may affect the efficiency
of accessing records.)
Cell
Relational keys
Each record in a table must be unique. This
means that we need to be able to identify a
column or combination of columns (called
relational keys) that provides uniqueness.
Super key
A column, or set of columns, that uniquely
identifies a record within a table. Eg. Student
Number, NSSF Number, National ID Number,
Bank Account Number, etc.
Relational keys …
Candidate key
A super key that contains only the minimum
number of columns necessary for unique
identification. Eg. Student Number, (NSSF
Number & Client Name), National ID Number,
(Bank Account Number & Account Name), (Name
& Tel Number), etc.
A candidate key for a table has two properties:
Uniqueness In each record, the values of the
candidate key uniquely identify that record.
Irreducibility No proper subset of the candidate
key has the uniqueness property.
Relational keys …
Primary key
The candidate key that is selected to identify
records uniquely within the table.
Foreign key
A column, or set of columns, within one table
that matches the candidate key of some
(possibly the same) table.
When a column appears in more than one
table, its appearance usually represents a
relationship between records of the two tables.
Relational keys Illustrated
Representing relational databases
A relational database consists of one or more
tables. The common convention for
representing a description of a relational
database is to give the name of each table,
followed by the column names in
parentheses. Normally, the primary key is
underlined.
Eg.
Branch (branchNo, street, city, state, zipCode,
mgrStaffNo)
Staff (staffNo, name, position, salary,
branchNo)
Relational integrity
A data model has two other parts: a
manipulative part, defining the types of
operations that are allowed on the data, and a
set of integrity rules, which ensure that the
data is accurate.
In this section, we discuss the relational
integrity rules, known as entity integrity and
referential integrity.
Null
Represents a value for a column that is currently
unknown or is not applicable for this record.
Relational integrity …
Entity integrity
In a base table, no column of a primary key
can be null.
A base table is a named table whose records
are physically stored in the database.
A view is a ‘virtual table’ that does not actually exist in
the database but is generated by the DBMS from the
underlying base tables whenever it’s accessed.
Relational integrity …
Referential integrity
If a foreign key exists in a
table, either the foreign key
value must match a candidate
key value of some record in its
home table or the foreign key
value must be wholly null.
Business rules …
Rules that define or constrain
some aspect of the
organization.
Summary
Relations are physically represented as tables, with the records
corresponding to individual tuples and the columns to attributes.
Properties of relational tables are: each cell contains exactly one
value, column names are distinct, column values come from the
same domain, column order is immaterial, record order is
immaterial, and there are no duplicate records.
A superkey is a set of columns that identifies records of a table
uniquely, while a candidate key is a minimal superkey. A primary
key is the candidate key chosen for use in identification of
records. A table must always have a primary key. A foreign key is
a column, or set of columns, within one table that is the candidate
key of another (possibly the same) table.
A null represents a value for a column that is unknown at the
present time or is not defined for this record.
Entity integrity is a constraint that states that in a base table no
column of a primary key can be null. Referential integrity states
that foreign key values must match a candidate key value of some
record in the home (parent) table or be wholly null.