Documente Academic
Documente Profesional
Documente Cultură
Experiment 1:
Student should decide on a case study and formulate the problem statement.
Solution:Case Study: University Database Application
Problem Statement:
Experiment 2:
Conceptual Designing using ER Diagrams (Identifying entities, attributes, keys and relationships
between entities, cardinalities, generalization, specialization etc.)
Note: Student is required to submit a document by drawing ER Diagram to the Lab teacher
Solution:-
Steps in E-R Modeling:Step- I: Identify the Entities: Look for general nouns in the given problem statement.
Generally the entities will have multiple instances in a given problem statement or business
scenario.
Step-II: Find Relationships: Identify the natural relationships and their cardinalities between
the entities.
Step-III: Identify the key attributes for every entity: Identify the attributes or set of attributes
which can identify instance of entity uniquely.
Step-IV: Identify other relevant attributes: Identify other attributes which are interest to
business users and want to store the information in database.
Step-V: Complete E-R diagram: Draw complete E-R diagram with all attributes including key
attributes and relationships among entities.
Page 1
Step-VI: Review your complete E-R diagram: Look at the list of attributes associated with
each entity to see if anything has been omitted.
DEPARTMENT
COURSE
INSTRUCTOR
STUDENT
Offers
Department
Course
2. One course is enrolled by multiple students and one student enrolls for multiple courses,
hence the relationship is many-to-many.
Course
Enrolled
by
Student
3. One department has multiple instructors and one instructor belongs to one and only one
department, hence the relationship is one-to-many.
Department
Instructor
Has
MLR Institute of Technology, Hyderabad
Page 2
4. Each department has one Head of department and one instructor is Head of
Department for only one department, hence the relationship is one-to-one.
Headed by
1
Department
Instructor
5. One course is taught by only one instructor but one instructor teaches many courses,
hence the relationship between course and instructor is many-to-one.
Course
Is taught by
Instructor
Page 3
Page 4
Experiment-3:
Converting ER Model to Relational Model (Represent entities and relationships in Tabular form,
Represent attributes as columns, identifying keys)
Note: Student is required to submit a document showing the database tables created from ER
Model.
Page 5
1. Key constraints:
There must be at least one minimal subset of attributes in the relation, which can identify a tuple
uniquely. This minimal subset of attributes is called key for that relation. If there are more than
one such minimal subset, these are called candidate keys.
Key constraints forces that:
In a relation with a key attribute, no two tuples can have identical value for key attributes.
Entity Integrity:
Relational Database Schema: A set of relation schemas that belong to the same database. S is the
name of the database
S = {R1, R2, ..., Rn}
Entity Integrity: The primary key attributes PK of each relation schema R in S cannot have null
values in any tuple of r(R). This is because primary key values are used to identify the individual
tuples.
t[PK] null for any tuple t in r(R)
2. Domain constraints
Attributes have specific values in real-world scenario. For example, age can only be positive
integer. The same constraints has been tried to employ on the attributes of a relation. Every
attribute is bound to have a specific range of values. For example, age cannot be less than zero
and telephone number cannot be a outside 0-9.
3. Referential Integrity Constraint
Statement of the constraint
The value in the foreign key column (or columns) FK of the the referencing relation R1 can be
either:
(1) a value of an existing primary key value of the corresponding primary key PK in the
referenced relation R2,, or..
(2) a null. In case (2), the FK in R1 should not be a part of its own primary key.
MLR Institute of Technology, Hyderabad
Page 6
Entity's attributes should become fields of tables with their respective data types.
2. Mapping Relationship
Mapping Process:
Create table for a relationship.
Add the primary keys of all participating Entities as fields of table with their
table.
Declare foreign key constraints.
Page 7
DEPARTMENT
SNo
15R21A050
1
15R21A050
2
15R21A040
1
15R21A030
2
COURSE
DNo
CName
DName
Duration
Location
ECE
JC208
Prerequisite
STUDENT
5
SName
3
S Jhonson
1
CSE
SR207
Gender
DOB
Email
MECH
AK307
M
21-05-1998 john@gmail.com
AERO
AK210
12
K Shiva
SR108 shiva@yahoo.com
M IT 15-02-1998
Address
Hyderabad
Vijayawada
CNo
P.Anitha
EC401
EC402
A.Keerthi
CS501
CS502
CS503
CS504
IName
101
K Srinivas
02-03-1998
ani@gmail.com
Bangalore
DLDF
45
days
Computer
basics
EDC
60 days
Physics
F
12-0-1999
keerthi@gmail.com
Hyderabad
C
60 days
Computer
basics
JAVA
60 days
C
DBMS
45 days
Computer basics INSTRUCTOR
Compile 45 days
TOC
Designation
RoomNo MobileNo
r
Associate Professor SR206 9849121211
102
M Aparna
Assistant Professor
SR105
103
V Karthik
Professor
AK302
104
K Srinivas
Professor
AK206
105
J Rajini
Assistant Professor
JC102
106
L Srinivas
Associate Professor
SR212
107
Y Pradeep
Assistant Professor
MT106
108
I Swathi
Professor
MT106
109
S Subash
Professor
SR203
INo
895745232
3
755585654
5
984912123
3
785858566
2
984921252
1
765685623
3
858321245
3
789845222
3
Page 8
2. Mapping Relationship
1. The department offers multiple courses and each course belongs to only one
department, hence cardinality between department and course is one-to-many.
DEPT_OFFERS_COURSE
DNo
CNo
EC401
EC402
CS501
CS502
12
CS503
12
CS504
2. One course is enrolled by multiple students and one student enrolls for multiple
courses, hence the relationship is many-to-many.
COURSE_ENROLL_INFO
CNo
SNo
EC401
15R21A040
1
15R21A050
1
15R21A040
1
15R21A050
1
15R21A030
2
15R21A040
1
EC401
EC402
EC402
CS501
CS501
Page 9
3. One department has multiple instructors and one instructor belongs to one and only
one department, hence the relationship is one-to-many.
DEPT_INSTRUCTOR
DNo
INo
101
103
102
104
108
105
106
12
107
109
4. Each department has one Head of department and one instructor is Head of
Department for only one department, hence the relationship is one-to-one.
Note: Here the mapping cardinality of the relationship is one-to-one, when it is one-to-one
relationship it is not necessary to create separate relation (or table) to show that relation.
Instead, we can simply add that column in the Department table itself.
DEPARTMENT
DNo
DName
Location
HOD
ECE
JC208
103
CSE
SR207
104
3
1
MECH
AERO
AK307
AK210
108
109
12
IT
SR108
107
Page 10
5. One course is taught by only one instructor but one instructor teaches many courses,
hence the relationship between course and instructor is many-to-one.
COURSE_INSTRUCTOR
CNo
INo
EC401
101
EC402
101
CS501
102
CS502
102
CS503
107
CS504
107
Experiment 4:
Normalization -To remove the redundancies and anomalies in the above relational tables,
Normalize up to Third Normal Form
Page 11