0% found this document useful (0 votes)
2 views3 pages

Assignement 1queries Using Join On Tables

The document outlines two database schemas: a Student-Teacher database and a Bank database, detailing their respective tables and relationships. It includes SQL queries to retrieve specific information, such as counting teachers with a Ph.D., finding student names associated with teachers, and analyzing loan applications at a bank branch. Additionally, it presents queries related to employee salaries, project budgets, and hours spent on projects.

Uploaded by

divypratap94
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Assignement 1queries Using Join On Tables

The document outlines two database schemas: a Student-Teacher database and a Bank database, detailing their respective tables and relationships. It includes SQL queries to retrieve specific information, such as counting teachers with a Ph.D., finding student names associated with teachers, and analyzing loan applications at a bank branch. Additionally, it presents queries related to employee salaries, project budgets, and hours spent on projects.

Uploaded by

divypratap94
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Q.

1) Join emp and emp_proj

Where emp.eno=emp_proj.eno

2) Join proj and emp_pro

Where proj.pno=emp_proj.pno

3) Join proj and emp


Where emp.eno=emp_proj.eno and proj.pnemp_proj.pno

1. Student- Teacher database


Consider the following database maintained by a school. The school maintains
information
about students and the teachers. It also gives information of the subject taught by the
teacher.
Following are the tables:
Student (sno , s_name, s_class , s_addr)
Teacher (tno , t_name , qualification ,join_date)
Stud_Teach(sno,tno,subject)

Insert into student values(1,’janhavi’, ‘FYBCA’,’pune’);

TEACHER (TNO INTEGER, T_NAME CHAR (20), QUALIFICATION CHAR


(15),join_date date)

Insert into teacher values (101,’punam’,’MCS, NET’, ‘13/1/2000’);

Stud_teach(sno,tno,subject)
Select count(tno) from stud_teach group by subject;

Insert into stud_teach values (1,101,’DBMS’);

The relationship is as follows:


STUDENT-TEACHER: M-M with descriptive attribute SUBJECT.
Stud_teach(sno,tno,subject)

Solve the queries


Find the number of teachers having qualification “Ph. D.”

Find student name of teacher Nilima

Display name of students who have opted mathematics subject.

Display number of teachers for each subject

Select count(tno) from stud_teach group by subject;

Display number of subjects selected by ‘riya’


Select count(subject) from student,stud_teach where
student.sno=stud_teach.sno and sname=’riya’;

Display information of teachers teaching to students of SYBCA class

2. Bank database
Consider the following database maintained by a Bank. The Bank maintains information
About its branches, customers and their loan applications.
Following are the tables:
BRANCH (BID INTEGER, BRNAME CHAR (30), BRCITY CHAR (10))

CUSTOMER (CNO INTEGER, CNAME CHAR (20), CADDR CHAR (35), CITY (20))

LOAN_APPLICATION (LNO INTEGER, LAMTREQUIRED MONEY, LAMTAPPROVED


MONEY, L_DATE DATE)
The relationship is as follows:
BRANCH, CUSTOMER, LOAN_APPLICATION are related with ternary relationship.
TERNARY (BID INTEGER, CNO INTEGER, LNO INTEGER).
Create table ternary (bid int references branch(bid) on delete cascade on update set
null,……)
Solve the Queries
1. Find the names of the customers for the “Aundh” branch.
2. List the names of the customers who have received loan less than their requirement.

3. Find the maximum loan amount approved.


4. Find out the total loan amount sanctioned by “Deccan “branch.
5. Count the number of loan applications received by “M.G.ROAD” branch.
6. List the names of the customer along with the branch names who have applied for
loan in the month of September.

Select customer.cname, branch.bname from customer,loan_application,branch where


and extract(moth from l_date) = 9
7. Display information of loan taken by ‘Mr.nene’

Q. 3
Employee ( eno,ename,salary,joindate,age,city)

Project (pno,pname,ptype,startdate,budget)

Project and emp are related with many to many relationship with descriptive attribute
n_of_hours

Pro_emp( eno*,pno*,no_of_hours)

Display name of employee having maximum salary


Display name and salary of employees working on project ‘robotics’, sorted by their
names in descending order
Display experience of all employees
Display maximum budget for each type of project
Display name of employees working on projects which are started on 23/04/2010
Display total no of hours spend on project named ‘chatbot’
Display name of city for which maximum minimum salary earned by employees is more
than 50000

You might also like