Escolar Documentos
Profissional Documentos
Cultura Documentos
A data model is a set of concepts that can be used to describe the structure of the database and the
different relationships and constraints which hold the data in the database.
Entities
An entity is an object of concern used to represent the things in the real world.
Ex: Car, Table, Book, Project, Loan etc.
Entity Set
A collection of a similar kind of entities is called an Entity set. Entity set need not be disjoint.
For example, the collection of all the students entities form a entity set STUDENT. Similarly collection of all
the courses form an entity set COURSE.
1
Primary Key
Primary key is an attribute or set of attributes used to identify every instance uniquely in a entity.
Weak Entity
Entity types that do not contain primary key attribute & hence cannot be identified independently, are
called Weak entity types.
Ex: Consider the entity type GUARDIAN/PARENT related to STUDENT entity, which is used to keep track
of the guardians related to students.
Attributes
An attribute is a property used to describe the specific feature of the entity.
For example, A STUDENT entity may be described by the student’s Reg-no, name, age, address, Course etc.
Reg_no: 1234
Name: Supriya
Age: 18
Address : Tumkur
Course: B.Sc
Domains
Each simple attribute of an entity type contains a possible set of values that can be attached to it.
For example, for PERSON entity person_id has a specific domain integer values say from 1 to 100.
Types of Attributes
1. Simple
The attribute that cannot be further divided into smaller parts is called simple attribute.
Ex: Reg_no, age
2. Composite
Attributes that can be divided into smaller units is called Composite attribute.
Ex: Name attribute can be divided into First_name & Last_name.
3. Single Valued
Attribute having a single value for a particular entity.
Ex: AGE
4. Multivalued
Attributesthat have more than one value for a particular entity is called a multivalued attribute.
Ex: Phone_no
5. Null Attributes
Attributes that does not have any values is called Null attribute.
6. Derived Attribute
An Attribute whose value is derived from the values of another attribute is termed as derived attribute
2
Ex: The years of experience (Services) of a PERSON entity can be determined from the current date &
the date of joining.
Relationships
An association among entities is called a relationship.
Ex: In COLLEGE database, the association between STUDENT & COURSE entity, i.e, “Students opts
Course”.
Relationship sets
A relationship set is a set of relationships of the same type.
Binary Relationship
A relationship is termed as binary if the number of entities involved in the relationship is two.
N-ary Relationship
A relationship which involves N entities is called an N-ary relationship.
Mapping Constraints
Two important mapping constraints are:
i. Mapping Cardinalities
ii. Existence dependencies.
i. Mapping Cardinalities
Cardinality specifies the number of instances of an entity associated with another entity
participating in a relationship.
Cardinality is classified into the following categories.
1. One to One
An entity in A is associated with at most one entity in B & vice versa.
Ex:
COLLEGE 1 1 PRINCIPAL
H
as
One college can have at the most one Principal & one principal can be assigned to only one
college.
2. One to many
An entity A is associated with any number of entities in B. An entity in B is associated with at the most
one entity in A.
Ex:
DEPARTMENT 1 Works N FACULTY
in
One department can appoint any number faculty members but a faculty member is assigned to only
one department.
3. Many to one
3
An entity in A is associated with at most one entity in B. An entity in B is associated with any number
in A.
Ex:
COURSE M Teach 1 FACULTY
es
An faculty can teach various courses but a course can be taught only by one faculty.
( Note: This is assumption)
4. Many to Many
Entities in A & B are associated with any number of entities from each other.
Ex:
BOOK M Teach N AUTHOR
es
One author can write many books & one book can be written by more than one author.
Keys
1. Super Keys
A super key is an attribute or set of attributes used to identify the instances uniquely in a entity set.
2. Primary Keys
A primary key is an attribute used to identify the instances uniquely & should be not null.
3. Candidate Keys
Candidate keys are minimal super keys. i.e, it contains two or more attributes which uniquely
identifies an instance of an entity set. For ex: In the relation PERSON the two possible candidate keys
are Person_id & name (Assuming unique names in the table), Person_id may be chosen as the primary
key
4. Secondary Key
It is an attribute or combination of attributes that may not be a candidate key but that classifies
the entity set on a particular characteristics.
E-R Diagram
We can express the overall logical structure of a database using E-R model graphically with the help of an E-
R diagram.’
4
Rectangles Represents entity
Double
Weak entity
Rectangle
Diamond Relationship
Double Identifying
Diamond relationship
Ellipses Attribute
Double
Multivalued attribute
Ellipses
Key Attribute
Composite Attribute
Derived Attribute
E1 E2 Total participation of
R E2
5
E-R diagram of COLLEGE Database
STUDENT
Op COURSE
ts
Taught
by
H Enroll
a ed ID
s
Dept_Name
Guardian Dept_no
Nam Basic_sa
e l
Relationship
Nam Addr
e
Hea
d of
Date_from
6
Assignment:
An employee works for a department. If the employee is a manager then he/she manages the department. As
an employee the person works for the project and the various departments of a company control those
projects. An employee can have many dependents. Draw an E-R diagram for the above company. Try to find
out all possible entities and relationships among them.