Experiment 3 Normalization
Experiment 3 Normalization
NORMALIZATION
AIM: Apply the database Normalization techniques for designing relational database tables to minimize
duplication of information like 1NF, 2NF, 3NF, BCNF.
Normalization is a process of converting a relation to be standard form by decomposition a larger relation into
smaller efficient relation that depicts a good database design.
1NF: A Relation scheme is said to be in 1NF if the attribute values in the relation are atomic.i.e., Mutli –valued
attributes are not permitted.
2NF: A Relation scheme is said to be in 2NF,iff and every Non-key attribute is fully functionally dependent on
primary Key.
3NF: A Relation scheme is said to be in 3NF,iff and does not have transitivity dependencies. A Relation is said
to be 3NF if every determinant is a key for each & every functional dependency.
BCNF: A Relation scheme is said to be BCNF if the following statements are true for eacg FD P->Q in set F of
FDs that holds for each FD. P->Q in set F of FD’s that holds over R. Here P is the subset of attributes of R & Q
is a single attribute of R.
P is a super key.
[12]
Normalized tables are:-
Mysql> Create table Reservation2(PNRNO integer Primary key, JourneyDate DateTime,NoofSeats int,Address
varchar(20),ContactNo Integer);
Mysql> Create table Ticket2(TicketNo Integer Primary key,JourneyDate DateTime, Age Int(4),Sex char(2),Source
varchar(20),Destination varchar(20),DeptTime varchar(2));
Viva Questions:
1.Define Redundancy?
2.What is decomposition?
3.What is Normalization?
4.What is fully functional dependency?
5.List the different types of Normal forms?
[13]
EXPERIMENT – 4
PRACTICING DDL COMMANDS
[14]
Mysql>Alter Table passenger3 add Foreign key(TicketNo) references Ticket(TicketNo);
[15]
Mysql>Alter table passenger drop foreign key fk1;
Viva Questions:
1.What is DDL?
5.Define Database?
[16]
EXPERIMENT – 5
PRACTICING DML COMMANDS
AIM: Create a DML Commands are used to manage data within the scheme objects.
DML Commands:
[17]
mysql> select * from Bus2;
[18]
mysql> select * from Passenger2;
[19]
UPDATE COMMAND ON BUS2 RELATION
mysql> Update Bus2 SET Source='Secundrabad' where BusNo=1234; Query OK, 1 row affected (0.05 sec)
[20]
DELETE COMMAND ON BUS2 RELATION
mysql> Delete from Bus2 where BusNo=1234; Query OK, 1 row affected (0.05 sec)
[21]
mysql> Delete from Bus2 where Source=’Secundrabad’; Query OK, 1 row affected (0.05 sec)
Viva Questions:
1.What is DML?
2.What is the use of DML in DBMS?
3.What are the DML Commands?
4.What is the use of Alter command in DBMS?
5.Define view?
[22]
EXPERIMENT – 6
Querying (using ANY, ALL, IN, Exists, NOT EXISTS, UNION, INTERSECT, Constraints etc.)
[23]
mysql> insert into passenger2 values(82302,'Smith',23,'M','Hyderabad');
PNR_No
10201
10202
10203
10204
[25]
2. Display all the names of male passengers.
[26]
[27]
3. Display the ticket numbers and names of all the passengers.
[28]
4. Find the ticket numbers of the passengers whose name start with ‘r’ and ends with ‘h’.
Name
Rajesh
Ramesh
Ramesh
[29]
5. Find the names of Passengers whose age is between 30 and 45.
[30]
6. Display all the passengers names beginning with ‘A’.
Name
Akash
Arivind
Avinash
[31]
7. Display the sorted list of Passengers names
Viva Questions:
[32]
EXPERIMENT – 7
Querying Aggregate Functions (GROUP BY, HAVING and Creation and Dropping of Views)
1. Write a Query to display the information present in the passenger and cancellation
tables
2. Display the number of days in a week on which the AP123 bus is available
3. Find number of tickets booked for each PNR_ No using GROUP BY CLAUSE
4. Find the distinct PNR Numbers that are present.
1. Write a Query to display the information present in the passenger and cancellation tables
[33]
MySQL> SELECT * FROM RESERVATION UNION
[34]
3. Find number of tickets booked for each PNR_No using GROUP BY CLAUSE
[35]
5 Mysql> select sum(Noofseats) from Cancellation2;
[36]
Creation and Droping of Views
mysql> create table students(sid int primary key,name varchar(15),login varchar(15), age
int,gpa real); mysql> create table Enrolled(sid int,cid int,grade varchar(5),primary
key(sid,cid), foreign key(sid) references students(sid));
E.grade='B';
Viva Questions:
[37]