Sunteți pe pagina 1din 11

Case Study: I -University Database Application

Experiment 1:
Student should decide on a case study and formulate the problem statement.
Solution:Case Study: University Database Application
Problem Statement:

An university has many departments.


Each department has multiple instructors; one among them is the head of the department.
An instructor belongs to only one department.
Each department offers multiple courses, each of which is taught by a single instructor.
A student may enroll for many courses offered by different departments.

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.

MLR Institute of Technology, Hyderabad

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.

Let us apply the above methodology to University database application


Step- I: Identify the Entities:
1.
2.
3.
4.

DEPARTMENT
COURSE
INSTRUCTOR
STUDENT

Note-1: Head of the department is NOT an Entity. It is a relationship between the


instructor and department entities.
Note-2: One may be tempted to identify university as an entity, but it is a false entity
because it has only one instance.

Step-II: Find Relationships:


We can derive the following relationships:
1. The department offers multiple courses and each course belongs to only one department,
hence cardinality between department and course is one-to-many.

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

Step-III: Identify the key attributes for every entity:


1. DNo (Department Number) which identifies the department uniquely will be the key
attribute for DEPARTMENT entity.
2. SNo (Student Number) is the key attribute for STUDENT entity.
3. INo (Instructor Number) is the key attribute for INSTRUCTOR entity.
4. CNo (Course Number) is the key attribute for COURSE entity.

Step-IV: Identify other relevant attributes:


1. For the Department entity, the relevant attribute other than Department Number is
Location.
2. For the Course entity, the relevant attributes other than Course Number are Course
Name, Duration and Pre Requisite.
3. For the Instructor entity, the relevant attributes other than Instructor Number are
Instructor Name, Designation, Room Number and Mobile Number.
4. For the Student entity, the relevant attributes other than Student Number are Student
name, Date of Birth, Gender, Email and Address

MLR Institute of Technology, Hyderabad

Page 3

Step-V: Complete E-R diagram:


Note-1: The students are required to submit a document by drawing the ER-Diagram of
University Database to the lab teacher.
Note-2: Students are suggested to use any online tools like erdplus.com or draw.io for drawing
ER-Diagram

MLR Institute of Technology, Hyderabad

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.

THEORY ABOUT RELATIONAL DATA MODEL

Relational data model:


Relational data model is the primary data model, which is used widely around the world for data
storage and processing. This model is simple and have all the properties and capabilities required
to process data with storage efficiency.
Concepts
Relation: A Relation is table of values. A relation may be thought of as a set of rows. A relation
may alternately be thought of as a set of columns. Each row represents a fact that corresponds to
a real-world entity or relationship. Each row has a value of an item or set of items that uniquely
identifies that row in the table.
Tuple: A tuple is an ordered set of values. Each value is derived from an appropriate domain.
Each row in the table may be referred to as a tuple. A domain may have a data-type or a format
defined for it.
Relation instance: A finite set of tuples in the relational database system represents relation
instance. Relation instances do not have duplicate tuples.
Relation schema: This describes the relation name (table name), attributes and their names.
Relation key: Each row has one or more attributes which can identify the row in the relation
(table) uniquely, is called the relation key.
Attribute domain: Every attribute has some pre-defined value scope, known as attribute
domain. A domain may have a data-type or a format defined for it.
Constraints
Every relation has some conditions that must hold for it to be a valid relation. These conditions
are called Relational Integrity Constraints.
Constraints are conditions three main types of constraints:
1. Key constraints
2. Entity integrity constraints
3. Referential integrity constraints
MLR Institute of Technology, Hyderabad

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.

Key attribute cannot have NULL values.

Key constrains are also referred to as Entity Constraints

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

Solution:Steps to convert E-R Model into Relational Model:


1. Mapping Entity
Mapping Process:
Create table for each entity.

Entity's attributes should become fields of tables with their respective data types.

Declare primary key.

2. Mapping Relationship
Mapping Process:
Create table for a relationship.
Add the primary keys of all participating Entities as fields of table with their

respective data types.


If relationship has any attribute, add each attribute as field of table.
Declare a primary key composing all the primary keys of participating entities.
Declare all foreign key constraints.

3. Mapping Weak Entity Sets


Mapping Process:
Create table for weak entity set.
Add all its attributes to table as field.
Add the primary key of identifying entity set.
Declare all foreign key constraints.
4. Mapping Hierarchical Entities
Mapping Process:
Create tables for all higher-level entities.
Create tables for lower-level entities.
Add primary keys of higher-level entities in the table of lower-level entities.
In lower-level tables, add all other attributes of lower-level entities.
Declare primary key of higher-level table and the primary key for lower-level

table.
Declare foreign key constraints.

MLR Institute of Technology, Hyderabad

Page 7

Note: The students need to submit a document by representing relationships in a tabular


fashion to the lab teacher.

Solution:Let us apply the above methodology to University database application


1. Mapping Entities

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

MLR Institute of Technology, Hyderabad

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

MLR Institute of Technology, Hyderabad

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

MLR Institute of Technology, Hyderabad

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

MLR Institute of Technology, Hyderabad

Page 11

S-ar putea să vă placă și