You are on page 1of 9

Name:

Roll No:

Submitted To:
Ma’am Shahista deen
Class:
BS (CS)
Semester:
4th
Subject:
Distributed Database
Project:
Final

Create Database Company


create table Student
(
Student_id varchar (10) not null,
Student_name varchar (50),
Student_title varchar (100),
Title varchar (100) not null,
primary key(Student_id),
foreign key (Title) REFERENCES Labour
)
insert into Student values ('EM1','Hamza Khan','Sales Department')
insert into Student values ('EM2','Ahmed Jutt','Chief Executive')
insert into Student values ('EM3','Saffi Gujjar','Head Constable')
insert into Student values ('EM4','Khizer Malhi','Doctor')
insert into Student values ('EM5','CH Sufyan','Engineer')
insert into Student values ('EM6','Muneeb Shah','Software Engineer')
insert into Student values ('EM7','Rana Kashif','Milk Farosh')

create table Teacher


(
Teacher_no varchar(10) not null,
Teacher_Name varchar(100),
Budget varchar (8000),
Location varchar (100),
primary key(Teacher_no)
)

insert into Teacher values('T1','DLD ','Lahore')


insert into Teacher values('T2','D Math ','Karachi')
insert into Teacher values('T3','Sofware Engineering','Islamabad')
insert into Teacher values('T4','Calculus 1 ','Faislabad')
insert into Teacher values('T5',' Calculus 3’,'Multan')
insert into Teacher values('T6',' Calculus 2','Sakkhar')
insert into Teacher values('T7','Biology ','Narowal')
insert into Teacher values('T8','Science','Muridke')
insert into Teacher values('T9','Chemistry','Checha Watni')

create table University


(

Duration varchar(10),
Student_id varchar (10) not null,
Teacher_no varchar (10) not null,
primary key(Duration),
foreign key(Student_id) REFERENCES Student,
FOREIGN key(Teacher_no) REFERENCES Teacher
)

insert into University values('1','EM1','a1')


insert into University values('2','EM2','a2')
insert into University values('3','EM3','a3')
insert into University values('4','EM4','a4')
insert into University values('5','EM5','a5')
insert into University values('6','EM6','a6')
insert into University values('7','EM7','a7')
insert into University values('8','EM8','a8')
insert into University values('9','EM9','a9')
insert into University values('10','EM10','a10')

create table Labour


(
Title varchar (100) not null,
Labour varchar (8000),
primary key(Title),

)
insert into Labour values('small','1000')
insert into Labour values('medium','2000')
insert into Labour values('big','3000')
insert into Labour values('high','4000')
insert into Labour values('extra small','5000')
insert into Labour values('extra large','6000')
insert into Labour values('extra big','7000')
insert into Labour values('starter','8000')
insert into Labour values('expert','9000')
insert into Labour values('beginner','10000')

select * from Student


select * from Teacher
select * from University
select * from Labour
Vertical Fragmentation of Student
select Student_id,Student_name
into vf1
from Student

select Student_title, Student_id


into vf2
from Student

Display vf1 and vf2


select * from vf1
select * from vf2

Reconstruction Of Vertical Fragmentation (basic Query)


select *
from vf1 join vf2
on
vf1.Student_id=vf2.Student_id

Horizontal Fragmentation of Student Table


select *
into h1
from Student
where Student_id ='E1'

--To Display h1
select * from h1
select *
into h2
from Student
where Student_id='E2'
--To Display h2
select * from h2

Reconstruction Of Horizontal Fragmentation


select * from h1
union all
select * from h2

Vertical Fragmentation Given In University


Select Teacher_no,Teacher_name,Budget
into vp1
from Teacher

--To Display vp1


select * from vp1

select Teacher_no,Location
into vp2
from Teacher

--To Display vp2


select * from vp2

--Reconstruction Vertical Fragmentation Given In Teacher


select *
from vp1 join vp2
on
vp1.Teacher_no=vp2.Teacher_no

--Horizontal Fragmentation Given In Teacher


select *
into hp1
from Teacher
where Teacher_Name='Database Development '

Show hp1
select * from hp1

select *
into hp2
from Teacher
where Teacher_no='P2'
select * from hp2

Reconstruction Of Horizontal Fragmentation Given In University


select * from hp1
union all
select * from hp2

Horizontal Fragmentation Given In University


select *
into ha1
from University
where Duration='1'
--To show ha1
select * from ha1

select *
into ha2
from University
where Duration='3'
--To show ha2
select * from ha2

Reconstruction of ha1 & ha2


select * from ha1
union all
select * from ha2

Horizontal Fragmentation of Labour


select *
into hs1
from Labour
where Title='M.M'

Display hs1
select * from hs1

select *
into hs2
from Labour
where Title='V.P.S'

Display hs2
select * from hs2

Reconstruction of hs1 and hs2


select * from hs1
union all
select * from hs2

You might also like