0% found this document useful (0 votes)
32 views

Name: Tathagat Shah STUDENTID: 201701053

This document contains SQL queries written by a student named Tathagat Shah for different databases including an academic database (ACAD), company database, supply parts database, and an XIT schema. The SQL queries retrieve data from tables using joins, filters, and other clauses. There are a total of 26 SQL queries divided into 4 sections based on the different databases.

Uploaded by

tathagat shah
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)
32 views

Name: Tathagat Shah STUDENTID: 201701053

This document contains SQL queries written by a student named Tathagat Shah for different databases including an academic database (ACAD), company database, supply parts database, and an XIT schema. The SQL queries retrieve data from tables using joins, filters, and other clauses. There are a total of 26 SQL queries divided into 4 sections based on the different databases.

Uploaded by

tathagat shah
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/ 7

NAME: TATHAGAT SHAH

STUDENTID: 201701053

COURSE: DATABASE MANAGEMENT SYSTEM (IT 214)

SQL CODE:

1) XIT SCHEMA:

set search_path to public;

a) select xit.department.did,xit.department.dname,xit.program.pid,xit.program.pname from


xit.department join xit.program on xit.department.did=xit.program.did;

b) select xit.student.studid,xit.student.name from xit.program join xit.student on


xit.student.progid=xit.program.pid where xit.program.pname='MTech(IT)' and xit.student.cpi>6.5;

c) select xit.student.studid,xit.student.name from xit.program join xit.department on


xit.department.did=xit.program.did join xit.student on xit.student.progid=xit.program.pid where
xit.department.did='EE' or xit.department.did='IT';

d) select * from xit.student join xit.program on xit.student.progid=xit.program.pid where


xit.student.batch='2012' and xit.program. pname='MSc(IT)';

2) COMPANY DATABASE:

set search_path to company;

a) select pname from company.project join company.department on


company.project.dno=company.department.dno join company.dept_locations on
company.department.dno=company.dept_locations.dno where
company.dept_locations.dlocation='Houston';

b) select e.fname,e.minit,e.lname,e.ssn,e.bdate,e.address,e.sex,e.salary,e.superssn,e.dno from


company.employee as e join company.employee as s on e.superssn=s.ssn where e.salary<s.salary;

c) select * from company.employee join company.dependent on


company.employee.ssn=company.dependent.essn where company.employee.dno='1';

d) select fname from company.employee join company.works_on on


company.employee.ssn=company.works_on.essn join company.project on
company.works_on.pno=company.project.pno where company.project.pname='ProductX' and
company.works_on.hours>2 and company.project.dno='5';

3) SUPPLY PARTS DATABASE:

set search_path to sales;

a)select * from items where category='5' and saleprice>'500';

b)select invno from customer join sales on customer.custid=sales.customerid where name='Allen';

c)select items.name from customer join sales on customer.custid=sales.customerid join salesdetails


on sales.invno=salesdetails.invno join items on salesdetails.itemcode=items.code where
sales.invdate='2011-08-23' and customer.name='John';

d)select customer.name from customer join sales on customer.custid=sales.customerid join


salesdetails on sales.invno=salesdetails.invno join items on salesdetails.itemcode=items.code where
items.category='c1';

4) ACAD DATABASE:

set search_path to acad;

(a)select coursename from acad.offers join acad.instructor on


acad.offers.instructorid=acad.instructor.instructorid join acad.course on
acad.offers.courseno=acad.course.courseno where acad.instructor.instructorname='P M Jat' and
acad.offers.acadyear='2010' and acad.offers.semester='Winter';

(b)select acad.student.studentid from acad.student join acad.registers on


acad.student.studentid=acad.registers.studentid where acad.registers.courseno='MT101' or
acad.registers.courseno='MT104';

(c)select acad.student.studentid from acad.student join acad.registers on


acad.student.studentid=acad.registers.studentid where acad.registers.courseno='MT101' and
acad.registers.courseno!='MT104';

(d)select acad.student.studentid,acad.student.name,cpi from acad.student join acad.registers on


acad.student.studentid=acad.registers.studentid where acad.registers.courseno='MT101' and
acad.registers.courseno='MT104' and acad.student.batch=2009;

e)select distinct student.studentid,name,cpi from student join registers on


registers.studentid=student.studentid where acadyear=2008 and semester=’Autumn’ except select
distinct student.studentid,name,cpi from student join registers on
registers.studentid=student.studentid where acadyear=2008 and semester=’Autumn’ and not
(grade=’AA’ or grade=’AB’);
f)select distinct student.studentid from student join result on result.studentid=student.studentid
where batch=2007 and progid=’01’ except select distinct student.studentid from student join result
on result.studentid=student.studentid where batch=2007 and progid=’01’ and not (spi>=6);

RELATIONAL ALGEBRA

You might also like