Professional Documents
Culture Documents
Relational Model (RM) represents the database as a collection of relations. A relation is nothing but
a table of values. Every row in the table represents a collection of related data values. These rows in
the table denote a real-world entity or relationship.
Entity Relationship Model (ER Modeling) is a graphical approach to database design. It is a high-level
data model that defines data elements and their relationship for a specified software system. An ER
model is used to represent real-world objects.
An entity is object, or component of data, that is easily identifiable. It is object in real world that is
distinguishable from the surrounding environment For example, in a university database,
students, lecturers, programs, and courses offered can be considered as entities. All these
entities have some attributes that describe them.
Attribute: Each column in a table is an attibute. Attributes are the properties which define a relation.
e.g. StudentId, StudentName, email etc. define the relation students
Reading Assignment: Read about the different types of attributes and suggest valid examples
Tables – In the Relational model the, relations are saved in the table format. It is stored along with its
entities. A table has two properties rows and columns. Rows represent records and columns
represent attributes.
Tuple – It is nothing but a single row of a table, which contains a single record.
Relation Schema: A relation schema represents the name of the relation with its attributes.
Degree: The total number of attributes which in the relation is called the degree of the relation.
Column: The column represents the set of values for a specific attribute.
Relation instance – Relation instance is a finite set of tuples in the RDBMS system. Relation instances
never have duplicate tuples.
Relation key - Every row has one, two or multiple attributes, which is called relation key.
Reading Assignment: Distinguish between a superkey, candidate key, and a primary key
Attribute domain – Every attribute has some pre-defined value and scope which is known as attribute
domain
Relationship - is used to describe the association between entities. The number of participating
entities in a relationship defines the degree of the relationship.
Reading Assignment: Read about 1:1, 1:m, m:1, and m:m relationships
1
ER Modeling Symbols and Notations
ER Modelling contains three basic symbols which are rectangle, oval and diamond to represent
relationships between elements, entities and attributes. The following are the main components and its
symbols in ER Diagrams:
Reading Assignment: Read about weak relationships, weak entities, and Multivalued attributes
Entities
Attributes
Relationships
2
Disadvantages of using Relational Model
i. Few relational databases have limits on field lengths which can't be exceeded.
ii. Relational databases can sometimes become complex as the amount of data grows,
and the relations between pieces of data become more complicated.
iii. Complex relational database systems may lead to isolated databases where the
information cannot be shared from one system to another.
To develop an ER model for the above requirements, the following steps are taken.
1. Identify all the entities from the given requirement
2. Identify the relationship between the entities
3. Identify the cardinality of the relationships
4. Identify the attributes of each entity
5. Create a sketch of the model using a pen and paper
Assignment 1:
Consider a basic requirement using the following sentence.
Follow the same steps above / as demonstrated during the Lab session to draw an ER Model.
Assignment 2: MyLibSeat
MyLibSeat is a small application that utilizes database to enable the students of XYZ college to
reserve a library seat, for a session lasting a couple of hours. The two major entities in this case
are students—students who reserve library seats; and library seats —seats in the college library
inventory. In this problem we need to know what seats are reserved by which students on a given
3
day, or better still, a given hour. Thus, the verb “reserves” would obviously represent an important
relationship here.
seatno each seat is assigned a unique ID (painted at the back of the seat)
seat_type The type of the seat (also painted on the bow)
seat_color The color of the seat
Note:
A student can make many reservations, but each reservation involves only a single student.
Similarly, a seat can be allocated to many reservations, but only one seat is allocated to each
particular reservation.
Required:
4
3 Lesson 3: Relational Integrity Constraints
Relational integrity constraints in DBMS are referred to conditions which must be present for a valid
relation. Constraints on the Relational DBMS are divided into three main categories:
Domain Constraints
Key Constraints
Referential Integrity Constraints
Domain Constraints
Domain constraints can be violated if an attribute value is not appearing in the corresponding domain
or it is not of the appropriate data type. Each table has certain set of columns. Each column only allows
entry of same type of data, based on its specified data type during table definition. The column does
not accept values of any other data type.
Domain Constraint = data type + Constraints (NOT NULL / UNIQUE / PRIMARY KEY /
FOREIGN KEY / CHECK / DEFAULT)
Key Constraints
An attribute that can uniquely identify a tuple in a relation is called the key of the table. The value of
the attribute for different tuples in the relation has to be unique.
Example: In the given table, StudentID is a key attribute of students table. It is most likely
to have a single key for one student, StudentID =1 is only for the student name " Alex
Jones".
Example: In the example below, we have 2 relations, students and programs. The tuple
for ProgramID =11 in the programs relation is referenced twice in the relation students.
5
ProgramID Program DepartmentID
11 BSc. Computer Science 1
12 BSc. Statistics 2
13 BSc. Data Science 3
Operations in Relational Model
The basic update operations performed on relational database model are: Insert, update, delete
and select.
Example: From the programs relation, delete the tuple(s) with program name as “BSc. Data
Science”.
6
ProgramID Program DepartmentID
11 BSc. Computer Science 1
12 BSc. Statistics 2
14 BSc. Economics 7
The Delete operation could violate referential integrity if the tuple which is deleted is
referenced by foreign keys from other tuples in the same database.
Select Operation
Example: From the programs relation, select the tuples satisfying the condition Program=
‘BSc. Statistics’
Consider the following data requirements that were provided by a college to aid in the development of
their ERP system.
XYZ college is a higher learning institution that offers training in various disciplines such as
Pharmacy, Engineering, Music, among others. The college is structured into various departments
where each department runs one or more programs. For Example, the programs Diploma in
Pharmacy, and Certificate in Pharmacy are housed in the Department of Pharmacy. Each program
is composed of a finite number of course units. Course units are identified using unit codes, unit
titles, credit hours, and unit type. Some units are shared across several programs in the college.
For instance, course units of the type “common units” are shared by all programs in the college;
“departmental units” are shared by all programs in a department, while “core units” are not shared
at all.
Students in the college are identified using admission number, names, email, phone, etc. A student
can be enrolled to only one program. The college maintains a register of Trainers using their
employment number, names, email, phone, ID number etc. In addition, each trainer belongs to one
of the various departments of the college.
The college adopts learning terms, which runs concurrently for all programs. Each term has a
name, start date, end date, exam date as its attributes e.g. the term “JAN_MAR_2020” begins on
01/01/2020, and ends on 31/03/2020, and exams begin on 23/03/2020.
At the onset of each term, a sub set course units are offered by each department. Students can only
register for one or more course units that have been put on offer. A trainer is assigned to teach one
or more course units that are on offer. Thus, a separate entity “courses on offer” is maintained
with the following attributes: course unit, term, trainer, venue, date, and time.
Required:
i. Identify and list all entities that can be derived from these requirements.
ii. Identify and list the relationships between the entities in (i) above, where applicable.