DB - Chapter 3
DB - Chapter 3
Model
E-R Model
● A true data entity will have many possible instances, each with a
distinguishing characteristic.
● In the context of Namal University which of the following can be identified
as entity?
STUDENT, RECTOR, FACULTY, CHAIR, EXAM, SCHEDULE, ROOM,
NAMAL
Entity
● Definition should make it clear what entity instances are included and not
included in the entity type; often, it is necessary to list the kinds of entities that
are excluded.
Example: A customer is a person or organization that has placed an order for
a product from us or one that we have contacted to advertise or promote our
products. A customer does not include persons or organizations that buy our
products only through our customers, distributors, or agents.
Defining Entity
Required: An attribute that must be present for each entity instance is called a
required attribute. E.g Name, Roll No etc.
Optional: An attribute that may not have a value is called an optional attribute. E.g
Phone No, Email etc.
A symbol might appear in front of each attribute to indicate whether it is required (*)
or optional (o), or required attributes will be in boldface, whereas optional attributes
will be in normal font.
Simple Versus Composite Attribute
Simple: An attribute that cannot be broken down into smaller components that are
meaningful to the organization. E.g: Vehicle ID, Color, Weight
Composite: An attribute that has meaningful component parts (attributes). The
components of composite attribute are written in round bracket separated by a
comma.
Single-Valued Versus Multi-Valued Attribute
Stored: An attribute that remain constant and fixed for an entity instance and must
be stored in relation.
Derived: An attribute whose values are based on other attributes and are not stored
directly in the database. It can be indicated with curly brackets around the attribute
name
Identifier Attribute
EMPLOYEE or
COURSE entity
Attributes on Relationships
● It is probably obvious to you that entities have attributes, but attributes may be
associated with a relationship (one-to-one, many to many) too.
● Hence Date Completed is a property of the relationship Completes, rather than a
property of either entity.
Associative Entity
A company wishes to store data about its product and order. They want to store
Product ID, Product Description, Product Price, Order ID, Order Date and Product
Quantity.
Degree of a Relationship
A rule that specifies the number of instances of one entity that can (or must) be
associated with each instance of another entity.
PATIENT Has Recorded PATIENT HISTORY: Each patient has one or more
patient histories. Each instance of PATIENT HISTORY “belongs to” exactly one
PATIENT.
Cardinality Constraint - Example
We have to make a system to keep the record of some songs. There are multiple
singers, each of whom have sung multiple songs. Some of the songs are sung by
multiple singers together. There are different cassettes available in the market,
which contain a mix of different songs. A song can be repeated in multiple
cassettes. All the cassettes are produced by some production companies, while
multiple production companies cannot co-produce a cassette.
You are required to create a conceptual data model of the data requirements for a
company that specializes in IT training. The Company has 30 instructors and can
handle up to 100 trainees per training session. The Company offers five advanced
technology courses, each of which is taught by a single teaching team. Each
instructor is a part of at-least one teaching teams or may be assigned to do a
research project which is assigned to only one instructor. Each trainee undertakes
one advanced technology course per training session.. There can be many
training sessions of a course throughout a year.