Uploaded by Mah Ru

database lab 4

advertisement
drop database Lab4MahamDB
create database Lab4MahamDB
create table Employees
(
Eid int not null ,
FullName varchar(30),
Dept varchar(20),
primary key (Eid)
);
create table Payrolls (
Eid int, Salary int,
foreign key(Eid) references Employees(Eid)
);
create table Departments (
Did int,
Eid int,
DeptName varchar(30),
foreign key(Eid) references Employees(Eid)
);
create table Projects
(
Pid int,
Eid int, PStatus varchar(20),
primary key (Pid),
foreign key(Eid) references Employees(Eid)
);
create table Tasks (
Tid int, Pid int,
foreign key(Pid) references Projects(Pid)
);
insert into Employees values('11','Maham Tahir','Development');
insert into Employees values('12','Ali','HR');
insert into Employees values('13','Aliyar','Finance');
select *from Employees
insert into Payrolls values('11',30000);
insert into Payrolls values('12',50000);
insert into Payrolls values('13',20000);
select *from Payrolls
insert into Departments values('1','11','Development');
insert into Departments values('2','12','HR');
insert into Departments values('3','13','Finance');
select *from Departments
insert into Projects values('14','11','In-Progress'); insert into Projects values('17','12','Completed');
insert into Projects values('18','13','In-Progress'); select *from Projects
insert into Tasks values('012','14'); insert into Tasks values('013','17'); insert into Tasks values('014','18'); select *from Tasks
Download