Professional Documents
Culture Documents
Lab 3 Database
Lab 3 Database
Laboratory 3
Title of the Laboratory Exercise: data model to relational model
1. Introduction and Purpose of Experiment
The ER schema is to be converted into a relational schema as data cannot be stored in an ER
schema. A relation schema gives the basic information describing a table or relation. It is the
logical definition of a table. This includes a set of column names, and the data types
associated with each column. By doing this lab, students will be able to map ER schema to
relational schema.
2. Aim and Objectives
Aim
To map data model to relational model
Objectives
At the end of this lab, the student will be able to
Map ER schema to relational schema
Insert tuples using SQL commands for the developed database schema
3. Experimental Procedure
i. Map all the components in the ER diagram to corresponding relation entities
and instances
ii. Insert tuples using SQL commands
iii. Design SQL commands using aggregate functions in SQL
iv. Execute SQL commands
v. Test the executed commands
vi. Document the Results
vii. Analyse and discuss the outcomes of your experiment
4. Questions
a. Consider the ER diagram you have drawn in Laboratory 2. Convert the ER diagram to
corresponding relational database schema.
b. Insert the tuples (minimum five) for the developed database schema using SQL
commands. Perform aggregate functions in SQL based on the developed database
schema.
5. Calculations/Computations/Algorithms
As requirements for railway reservation system are:
1. Display the reservation chart
2. Count the number of births empty in train coach wise
3. List the trains passing through a particular station
The entity required for this model will be train, station, reservation. Attribute for train will be train
number, start station code, destination station code, number of births. Attribute for station will be
station code, station name. attribute for reservation will be PNR, passenger name, age, gender, train
number, birth number, journey date.
- As reservation chart has to be displayed so it will contain passenger name, age, gender etc.
- As there should be count of the number of births empty in train coach wise so, total number
of
births, birth number in reservation relation is necessary.
Name: Pritam Das Roll Number: 17ETCS002130
- As there should be a list of trains passing through a particular station, so all the train will
have
attribute as start station code and end station code.
- Attributes as train number, station code, PNR will be primary key.
- Some attributes as train number in reservation relation will be foreign key as it is referencing
to a
different relation. Using all this information, we’ll make relation schema in MySQL.
6. Presentation of Results
reservation
pnr CHAR(10)
passengerName CHAR(20)
age INT(11)
sex CHAR(12)
trainNo CHAR(50)
bearthNo CHAR(3)
last_name CHAR(15)
uno CHAR(10)
email VARCHAR(100)
pass CHAR(15)
contact CHAR(15)
address VARCHAR(20)
u_type VARCHAR(20)
Indexes
A database schema usually specifies which columns are primary keys in tables and which
other columns have special constraints such as being required to have unique values in each
record. It also usually specifies which columns in which tables contain references to data in
other tables, often by including primary keys from other table records so that rows can be
easily joined. These are called foreign key columns.
A database schema is ultimately implemented in SQL through CREATE statements. These are
commands to the database program to build (or create) tables with certain specifications.
They specify which column constitutes a primary key, what type of data each column stores,
and which are foreign keys referencing other.
9. Comments
1. Limitations of Experiments
Object identity: In entity-relationship modelling, explicit object types, such as Employee,
Department, Project, etc., are specified. In the relational model, these may survive only as
names of relations. · In the relational model, entities have no independent identification or
existence. Objects can only be identified and accessed indirectly via the identification of
those attributes which characterize them.
the schema (or structure) of all records in a table must be the same. If you've encountered
tables with many empty columns for optional fields, it's a result of this rigidity. Tables with
many empty columns waste a lot of space.
Schema changes are heavyweight. If you have even one record which needs a new field, you
must add it to every record in the table. In a document-oriented database, adding a new
field to one document doesn't affect any of the other documents (it may however, increase
the size of your index if you will use that field to search for documents). This makes schema
changes lightweight and relatively easy to carry out.
3. Learning happened
How to map data model to relational model
how to make database schema in MySQL
learnt about primary key, foreign key
learnt about different categories of constraints of database
4. Recommendations
be careful while selecting primary key
be careful in selecting foreign key that will reference to other relation.
keep all the constraint in mind