Lesson02 ER Modelling
Lesson02 ER Modelling
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 Modeling (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. It can be an object with either physical
existence (eg. student, patient, customer, products) or conceptual existence (eg. orders,
treatments, registrations,). 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 attribute. 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
1
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
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
v. Data independence: The Structure of Relational database can be changed without
having to change any application.
vi. Scalable: Regarding a number of records, or rows, and the number of fields, a
database should be enlarged to enhance its usability.
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.
“In a hospital there are doctors who treat patients. The treatment may entail the patients being
prescribed one or more drugs”
Follow the same steps above / as demonstrated during the Lab session to draw an ER Model.
Assignment 2:
Consider a basic requirement using the following sentence.
3
“In MUST there are drivers who are assigned to drive vehicles. ”
Follow the same steps above / as demonstrated during the Lab session to draw an ER Model.
Assignment 3: 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
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: