Академический Документы
Профессиональный Документы
Культура Документы
Creation of tables:
Insertion:
Queries:
1.Write a query to display name of a person and the car he/she owns?
Select p.name,c.model
from person26 p,car26 c,owns26 o
where p.driverid=o.drivid and c.regno=o.regdno;
2.Write a query to check a person with a specific id has met with an accident in the year
2003-04.
select p.driverid from person26 p,participated26 p1,accident26 a where
p.driverid=p1.driverid and a.repno=p1.repno and a.adate like '%03';
3.A query to find the total number of people with who won the cars that were involved in
the accident in the year 2002.
select count(*) from person26 p,participated26 p1,accident26 a,owns26 o where
p.driverid=o.drivid and a.repno=p1.repno and a.adate like '%02';
4.Find the no. of accidents in which cars belonging to specific model where involved.
Select c.model,count(c.model) from accident26 a,participated26 p,car26 c where
a.repno=p.repno and c.regno=p.regno group by c.model;
Database of an Employee:
Employee(fname,mname,lname,eno,dob,address,salary,supno,deptnum)
Department(deptname,deptnum,mgreno,mgrstartdate)
Departmentlocation(deptnum, deptloc)
Works-ON(eno,pno,hours)
Project(pname, pno, ploc,deptnum)
Dependent(eno, dependentname,dob,relationship)
Creation of tables:
Queries:
Retrieve the names of employees in the deptartment5 who works for more than 10 hrs for
the project name.
Select fname from employ26 where eno in (select eno from workson26 where pno
in(select pno from project26 where hours>10 and deptno=5));
Retrieve the names of employ who work on every project controlled by deptno=5
Select fname,lnamefrom employee where ((select pno from works-on26 where
eno=enum)contains (select pno from project26 where dno=5));
Retrieve the names of each employ who has a dependent with the same first name of
employ
Select fname,lname from employ26 where eno in (select eno from dependent26 where
fname=deptname);
Retrieve the eno of all employees who works on project num 1,2,3
Select distinct eno from works-on26 where pno in(1,2);
Consider the following relations for the details maintained by a book dealer.
Author(authorid,name,city,country)
Publisher(publisherid,name,city,country)
Catalog(bookid, title,authorid, publisherid, categoryid, year,price)
Category(categoryid, description)
Orderdetails(orderno, bookid, quantity)
Create the above tables properly by specifying the primary keys and foreign keys.
Enter altleast 4 to 5 tuples for each relation.
1. Give the details of the author who have two or more books in the catalog and the
price of the books is greater than the average price of the books in the catalog and the
year of publication is after 2000.
4. create a suitable front end for query and displaying the results.