You are on page 1of 2

create database 1NC15IS020;

use 1NC15IS020;
create table course(courseID int primary key not null,courseName
varchar(25),credits int);
desc course;
create table faculty(facultyID int primary key not null,facultyName varchar(25),
desig varchar(15), hod int,hiredate date,allowance int,phone int, courseID int
references COURSE(courseID));
desc faculty;
create table allowance(grade int primary key,lowlimit int, hilimit int);
desc allowance;

//INSERTING INTO TABLES

insert into course(courseID,courseName,credits)values(101,'MATHEMATICS',4),


(102,'PHYSICS',4),(201,'THERMODYNAMICS ',5),(301, 'COMPILER DESIGN',6),(302,
'DBMS', 6),(401,'ROBOTICS',5);
select *from course;

insert into faculty(facultyID,


facultyName,desig,hod,hiredate,allowance,phone,courseID)values(1001, 'SRINIVAS',
'PRINCIPAL', NULL, '1996-02-22', 9890, 988777666, NULL),(1010,' HARISH' ,'PROF
',1001, '1996-04-12', 7010, 988334568, 102),(1011,' RAMESH',' PROF', 1001,' 1996-
09-18', 6500, 888777333,201),(1021,'SURESH',' PROF', 1001 ,'1996-07-01', 6500,
777334567 ,301),(1031,' LAKSHMAN',' PROF', 1001,' 1998-06-09', 6700 ,333444566,
302),(2001,' GANESH',' LECTURER', 1010,' 2007-01-09', 3000, 333452345, 101),(2010,'
PHANEESH',' LECTURER', 1011 ,'2008-01-17', 2500, NULL ,201),(2020,' ARUN', 'ADHOC',
1021,' 2009-06-12', 2400, NULL, 301),(2030,' ARJUN',' LECTURER ',1031,' 2010-12-
13', 2600, 234568899,302
),(3010,' PARUL',' LABASSIST', 1011,' 2012-12-30', 2000 ,NULL ,301),(4010,'
SHARMA',' LECTURER', 1021,' 2017-12-12', 2000, 676775454,NULL);
select *from faculty;
insert into allowance(grade,lowlimit,hilimit)values(1,9001,10000),(2, 8001, 9000),
(3, 7001, 8000),
(4 ,6501 ,7000),
(5, 6001, 6500),
(6, 3001, 6000),
(7 ,2001 ,3000),
(8 ,1000, 2000);

//QUERIES

1.) select * from faculty where courseID in(201,301);


2.a) select * from faculty where allowance between 6001 and 7000;
2.b) select * from faculty where allowance < 7000 and allowance > 6000;
3.) select * from faculty where month(hiredate) in (1,3,5,7,9,11);
4.) select * from faculty where day(hiredate) > 15;
5.) select * from faculty where facultyName like 'P%' and allowance > 2000 and
courseID=201;
6.) select * from faculty where courseID = 302;
7.) select * from faculty where ((year(now())-year(hiredate))>20 and hod);
8.) select f.facultyID,f.facultyName,f.desig,a.grade,c.credits from faculty
f,allowance a,course c;
9.)
10.) select * from faculty where hiredate< ' 19980609';
11.) select * from faculty where courseID in (201,301) and desig != 'HOD';
12.)
13.)
14.)
15.) select facultyID, facultyName,desig,phone,max(allowance) as HIGH_PAID from
faculty;

You might also like