You are on page 1of 3

1.

2 Entity relationship diagram


Staff

Property
Staff

Owner

Property

Property Type

Property
Fitting

Fitting

Supplier

insert into property_staff values('9','','','','');

insert into property_staff (property_id,staff_type_id,start_of_assignment_date,No_of_Staff)


values('2','1','2013-09-01','3');
values('2','2','2013-09-01','1');
insert into property_staff values('6','1,'2005-06-01','2013-06-01','5');

insert into property_staff values('6','2', '2005-06-01','2013-06-01', '1');


insert into property_staff values('6','3', '2005-06-01','2013-06-01','1');
insert into property_staff values('6','7', '2005-06-01','2013-06-01','1');
insert into property_staff values('6','4', '2005-06-01','2013-06-01','1');
insert into property_staff values('6','5', '2005-06-01','2013-06-01','3');
**

values ('7','1','2010-06-30','10');
values ('7','2','2010-06-30','2');
values ('7','3','2010-06-30','1');
values ('7','7','2010-06-30','1');
values ('7','4','2010-06-30','1');
values ('7','5','2010-06-30','3');
values ('7','6','2010-06-30','6');
values('7','8','2010-06-30','1');

insert into property_staff (property_id,staff_type_id,start_of_assignment_date,No_of_Staff)

insert into property_staff (property_id,staff_type_id,start_of_assignment_date,No_of_Staff)


values ('9','3','2013-01-01','1');
insert into property_staff values ('1','7','2005-09-01','2006-09-01','1');

-- Select * from property;

select p.property_id, p.property_name, p.property_address, p.owner_id, p.property_type_id,


o.owner_name,o.owner_address, o.owner_telephone_no, pt.property_type
,ps.staff_type_id,s.staff_type,s.staff_type_id,pf.fitting_id,pf.property_id,f.fitting_id,f.fitting_name
from property p, owner o, property_type pt ,property_staff ps, staff s, property_fitting pf, fitting f
where p.owner_id = o.owner_id

and p.property_type_id = pt.property_type_id


and p.property_id=ps.property_id
and ps.staff_type_id=s.staff_type_id
and p.property_id=pf.property_id
and pf.fitting_id=f.fitting_id and o.owner_id="001";

Query 2
Select p.property_id, p.property_name,p.property_address,p.property_type_id,
ps.staff_type_id,s.staff_type,ps.No_of_Staff

From property p,property_staff ps ,staff s


where p.property_id=ps.property_id
and ps.staff_type_id=s.staff_type_id
and ps.staff_type_id='3';

query 3
select p.owner_id, o.owner_name,o.owner_address, o.owner_telephone_no,p.property_id,
p.property_name, p.property_address, p.property_type_id, pt.property_type
from property p, owner o, property_type pt
where p.owner_id = o.owner_id
and p.property_type_id = pt.property_type_id

and p.property_type_id="10023";
query4

query 5

You might also like