0% found this document useful (0 votes)
44 views18 pages

C83PC5-DBMS Lab Manual 2021 (Exp 4-6)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views18 pages

C83PC5-DBMS Lab Manual 2021 (Exp 4-6)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Experiment 4

NORMALIZATION OF TABLES

Aim: Apply the database Normalization techniques for designing relational database tables to
minimize duplication of information.

Normalization: Normalization is the process of reorganizing data in a database so that it meets


two basic requirements: (1) There is no redundancy of data (all data is stored in only one place),
and (2) data dependencies are logical (all related data items are stored together). Normalization is
important for many reasons, but chiefly because it allows databases to take up as little disk space
as possible, resulting in increased performance.
Normalization is also known as data normalization.
The three main types of normalization are listed below.
Note: "NF" refers to "normal form."

 1NF
 2NF
 3NF

The following three NFs exist but are rarely used:

 BCNF
 4NF
 5NF

BUS:

Bus_no Source Destination

Passenger:

Pnr_No Ticket_no Name Age Sex PPNO

1
Reservation:

Pnr_No Journey_date No_of_seats Address Contact_No Status

Cancellation:

Pnr_No Journey_date No_of_seats Address Contact_No Status

Ticket:

Ticket_No Journey_date Age sex source Destination Dep_time

2
Experiment 5

Aim: Installation of MySQL and practicing DDL commands.


1. Steps for installing MySQL

Step 1
Make sure you already downloaded the MySQL essential 5.0.45 win32.msi file. Double click
on the .msi file.

Step 2
This is MySQL Server 5.0 setup wizard. The setup wizard will install MySQL Server 5.0 release
5.0.45 on your computer. To continue, click next.

Step 3
Choose the setup type that best suits your needs. For common program features select Typical
and it’s recommended for general use. To continue, click next.

3
Step 4

This wizard is ready to begin installation. Destination folder will be in C:\Program


Files\MySQL\MySQL Server 5.0\. To continue, click next.

Step 5
The program features you selected are being installed. Please wait while the setup wizard installs
MySQL 5.0. This may take several minutes.

4
Step 6
To continue, click next.

Step 7
To continue, click next.

5
Step 8
Wizard Completed. Setup has finished installing MySQL 5.0. Check the configure the MySQL
server now to continue. Click Finish to exit the wizard

d.

Step 9
The configuration wizard will allow you to configure the MySQL Server 5.0 server instance. To
continue, click next.

6
Step 10
Select a standard configuration and this will use a general purpose configuration for the server
that can be tuned manually. To continue, click next.

Step 11

Check on the install as windows service and include bin directory in windows path. To
continue, click next.

7
Step 12
Please set the security options by entering the root password and confirm retype the password.
To continue, click next.

Step 13
Ready to execute? Clicks execute to continue.

8
Step 14
Processing configuration in progress.

Step 15
Configuration file created. Windows service MySQL5 installed. Press finish to close the wizard.

9
10
Experiment 6

2.Practicing DDL commands

1.1 CREATE Table

a) Passenger Table

SQL> create table Passenger(PNR_NO Integer primary key , Ticket_NO Integer, Name
varchar(20), Age Integer, Sex char(10), PPNO varchar(15));

Table created.

SQL> desc passenger

Name Null? Type

----------------------------------------- -------- ----------------------------

PNR_NO NOT NULL INTEGER

TICKET_NO INTEGER

NAME VARCHAR2(20)

AGE INTEGER

SEX CHAR(10)

PPNO VARCHAR2(15)

b) Reservation Table

SQL> create table Reservation(PNR_NO Integer, No_of_seats Integer, Address varchar(50),


Contact_No Integer, Status char(3));

Table created.

SQL> desc Reservation

Name Null? Type

----------------------------------------- -------- ----------------------------

PNR_NO INTEGER

NO_OF_SEATS INTEGER

ADDRESS VARCHAR2(50)

11
CONTACT_NO INTEGER

STATUS CHAR(3)

c) Bus Table

SQL> create table Bus(Bus_No varchar(5) primary key, source varchar(20), destination
varchar(20));

Table created.

SQL> desc bus;

Name Null? Type

----------------------------------------- -------- ----------------------------

BUS_NO NOT NULL VARCHAR2(5)

SOURCE VARCHAR2(20)

DESTINATION VARCHAR2(20)

d) Cancellation Table

SQL> create table Cancellation(PNR_NO Integer, No_of_seats Integer, Address varchar(50),


Contact_No integer, Status char(3));

Table created.

SQL> desc Cancellation

Name Null? Type

----------------------------------------- -------- ----------------------------

PNR_NO INTEGER

NO_OF_SEATS INTEGER

ADDRESS VARCHAR2(50)

CONTACT_NO INTEGER

STATUS CHAR(3)

e) Ticket Table

SQL> create table Ticket(Ticket_No Integer primary key, age Integer, sex char(4) Not

12
null, source varchar(2), destination varchar(20), dep_time varchar(4));

Table created.

SQL> desc Ticket

Name Null? Type

----------------------------------------- -------- ----------------------------

TICKET_NO NOT NULL INTEGER

AGE INTEGER

SEX NOT NULL CHAR(4)

SOURCE VARCHAR2(2)

DESTINATION VARCHAR2(20)

DEP_TIME VARCHAR2(4)

1.2 ALTER Table

SQL> ALTER TABLE Reservation ADD FOREIGN KEY (PNR_NO) REFERENCES


Passenger(PNR_NO);

Table altered.

SQL> ALTER TABLE Cancellation ADD FOREIGN KEY (PNR_NO) REFERENCES


Passenger(PNR_NO);

Table altered.

SQL> alter table Ticket add constraint check_age check(age>18);

Table altered.

1.3 INSERT

SQL> insert into Passenger (PNR_NO,TICKET_NO, 'Name', Age, Sex, PPNO)


values(1,1,’SACHIN’,12,’m’,sd1234);

Enter value for pnr_no: 1


Enter value for ticket_no: 1
Enter value for name: SACHIN
Enter value for age: 12
Enter value for sex: m
Enter value for ppno: sd1234

13
old 1: insert into Passenger (PNR_NO,TICKET_NO, 'Name', Age, Sex, PPNO)
new 1: insert into Passenger values(1,1,'SACHIN',12,'m','sd1234')
1 row created.
SQL> /

Enter value for pnr_no: 2


Enter value for ticket_no: 2
Enter value for name: rahul
Enter value for age: 34
Enter value for sex: m
Enter value for ppno: sd3456
old 1: insert into Passenger (PNR_NO,TICKET_NO, Name, Age, Sex, PPNO)

new 1: insert into Passenger values(2,2,'rahul',34,'m','sd3456');

1 row created.

SQL> /

Enter value for pnr_no: 3


Enter value for ticket_no: 3
Enter value for name: swetha
Enter value for age: 24
Enter value for sex: f
Enter value for ppno: sdqw34
old 1: insert into Passenger (PNR_NO,TICKET_NO, Name, Age, Sex, PPNO)

new 1: values(3,3,'swetha',24,'f','sdqw34');

1 row created.

SQL> /

Enter value for pnr_no: 4


Enter value for ticket_no: 4
Enter value for name: ravi
Enter value for age: 56
Enter value for sex: m
Enter value for ppno: sdqazx
old 1: insert into Passenger (PNR_NO,TICKET_NO, Name, Age, Sex, PPNO)

new 1: values(4,4,'ravi',56,'m','sdqazx')

1 row created.

SQL> /

14
Enter value for pnr_no: 4
Enter value for ticket_no: 5
Enter value for name: asif
Enter value for age: 33
Enter value for sex: m
Enter value for ppno: iuyhjk
old 1: insert into Passenger (PNR_NO,TICKET_NO, Name, Age, Sex, PPNO)

new 1: insert into Passenger values(4,5,'asif',33,'m','iuyhjk')*

SQL> select * from Passenger;

PNR_NO TICKET_NO NAME AGE SEX PPNO

---------- ---------- -------------------- ---------- ---------- ---------------

1 1 SACHIN 12 m sd1234

2 2 rahul 34 m sd3456

3 3 swetha 24 f sdqw34

4 4 ravi 56 m sdqazx

SQL> insert into Bus (Bus_No,source,destination);

Enter value for bus_no: 1


Enter value for source: hyd
Enter value for destination: ban
old 1: insert into Bus (Bus_No,source,destination)

new 1: insert into Bus values('1','hyd','ban')

1 row created.

SQL> /

Enter value for bus_no: 2


Enter value for source: hyd
Enter value for destination: chn
old 1: insert into Bus values('&Bus_No','&source','&destination')

15
new 1: insert into Bus values('2','hyd','chn')

1 row created.

SQL> /

Enter value for bus_no: 4


Enter value for source: hyd
Enter value for destination: mum
old 1: insert into Bus (Bus_No,source,destination)

new 1: insert into Bus values('4','hyd','mum')

1 row created.

SQL> /

Enter value for bus_no: 5


Enter value for source: hyd
Enter value for destination: kol
old 1: insert into Bus (Bus_No,source,destination)

new 1: insert into Bus values('5','hyd','kol')

1 row created.

SQL> /

Enter value for bus_no: 5


Enter value for source: sec
Enter value for destination: ban
old 1: insert into Bus (Bus_No,source,destination)

new 1: insert into Bus values('5','sec','ban')

insert into Bus values('5','sec','ban')

SQL> insert into Reservation (PNR_NO, No_of_seats, Address, Contact_No , Status);

Enter value for pnr_no: 1


Enter value for no_of_seats: 2
Enter value for address: masabtank
Enter value for contact_no: 9009897812

16
Enter value for status: s
old 1: insert into Reservation (PNR_NO, No_of_seats, Address, Contact_No,Status)

new 1: insert into Reservation values(1,2,'masabtank',9009897812,'s')

1 row created.

SQL> insert into Reservation (PNR_NO,No_of_seats,Address,Contact_No,Status);

Enter value for pnr_no: 8


Enter value for no_of_seats: 3
Enter value for address: cbt
Enter value for contact_no: 9090887753
Enter value for status: s
old 1: insert into Reservation (PNR_NO, No_of_seats, Address, Contact_No, Status)

new 1: insert into Reservation values(8,3,'cbt',9090887753,'s')

insert into Reservation values(8,3,'cbt',9090887753,'s')

1.4 UPDATE Table

SQL> update Passenger set age='43' where PNR_NO='2';

1 row updated.

SQL> select * from Passenger;

PNR_NO TICKET_NO NAME AGE SEX PPNO

---------- ---------- -------------------- ---------- ---------- ---------------

1 1 SACHIN 12 m sd1234

2 2 rahul 43 m sd3456

3 3 swetha 24 f sdqw34

4 4 ravi 56 m sdqazx

2.5 DELETE

17
SQL> delete from Passenger where PNR_NO='4';

1 row deleted.

SQL> select * from Passenger;

PNR_NO TICKET_NO NAME AGE SEX PPNO

---------- - --------- -------------------- ---------- ---------- ---------------

1 1 SACHIN 12 m sd1234

2 2 rahul 43 m sd3456

3 3 swetha 24 f sdqw34

1.5 DROP Table

SQL> drop table Cancellation;

Table dropped.

18

You might also like