0% found this document useful (0 votes)
35 views18 pages

Database Management

MYSQL databases

Uploaded by

amogh biyal
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)
35 views18 pages

Database Management

MYSQL databases

Uploaded by

amogh biyal
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/ 18

DATABASE

MANAGEMENT

Question-1:
Create a Database named INSTITUTE
Query:

AMOGH BIYAL | XII-L


Output:

Question-2:
Create a table named FACULTY with the following structure.
Table FACULTY

AMOGH BIYAL | XII-L


ATTRIBUTE DATATYPE CONSTRAINT
F_ID Integer PRIMARY KEY
Fname Text data with max length NOT NULL
25 characters
Lname Text data with max length NOT NULL and UNIQUE
25 characters
HIRE_DATE DATE
SALARY DECIMAL SIZE 7,2 Must be >= 5000

Query:

Output:

Question-3:
Create a table named COURSES with the following structure.
Table : COURSES

AMOGH BIYAL | XII-L


ATTRIBUTE DATATYPE CONSTRAINT
C_ID Text(10) PRIMARY KEY
F_ID Integer Foreign Key
CNAME TEXT SIZE 40 CHARS DEFAULT VALUE “BASIC
COURSE”
FEES DEFAULT SIZE 7,2

Query:

Output:

Question-4:
Insert following data records into FACULTY table and COURSES table.
FACULTY

AMOGH BIYAL | XII-L


F_ID Fname Lname Hire date Salary
102 Amit Mishra 12-10-1998 12000
103 Nitin Vyas 24-12-1994 8000
104 Rakshit Soni 18-5-2001 14000
105 Rashmi Malhotra 11-9-2004 11000
106 Sulekha Srivastava 5-6-2006 10000
107 Niranjan Kumar 26-8-1996 16000

COURSES

C_ID F_ID Cname Fees


C21 102 Grid Computing 40000
C22 106 System Design 16000
C23 104 Computer Security 8000
C24 106 Human Biology 15000
C25 102 Computer Network 20000
C26 105 Visual Basic 6000
C27 107 Dreamweaver 4000

Query:

Question-5:
To display all records from FACULTY table
Query:

AMOGH BIYAL | XII-L


Question-6:
To display all records from COURSES table
Query:

Question-7:
To display all records from FACULTY table whose Hire date is more than 05-OCT-2001

AMOGH BIYAL | XII-L


Query:

Question-8:
To display F_ID, Fname, Cname of those faculties who charged more than 15000 as fees.
Query:

Question-9:
Display faculty id and the count of number of courses handled by each faculty from courses
table
Query:

Question-10:
Display all records FACULTY table order by First Name of the faculty in descending order
Query:

AMOGH BIYAL | XII-L


Question-11:
Display Faculty id,faculty name,Salary and course name from faculty and courses table
Query:

Question-12:
To increase the fees of Dreamweaver course by 500.
Query:

AMOGH BIYAL | XII-L


Question-13:
Alter COURSES table to change size of CNAME field to varchar(50)
Query:

Question-14:
Alter FACULTY table to add a new field to Phone Number varchar(15)
Query:

AMOGH BIYAL | XII-L


Question-15:
Display distinct F_ID from COURSES table.
Query:

Question-16:
Display records from FACULTY table where Last name starts with ‘M’
Query:

AMOGH BIYAL | XII-L


Question-17:
Display today’s date
Query:

Question-18:
Display total and average fees from COURSES table.
Query:

Question-19:
Display Faculty names from FACULTY table who handle/teach more than one
Course(Nested Query)

AMOGH BIYAL | XII-L


Query:

Question-20:
Display all records from FACULTY table whose phone number is NULL
Query:

Question-21:
Show the structure of FACULTY table and COURSES table
Query:

AMOGH BIYAL | XII-L


Question-22:
Delete records from COURSES table having F_ID as 102
Query:

AMOGH BIYAL | XII-L


Output:

Question-23:
Delete all records from COURSES table
Query:

Output:

Question-24:
Revoke the last delete operation
Query:

AMOGH BIYAL | XII-L


Question-25:
Drop COURSES table.
Query:

Question-26:
Write the outputs of the SQL queries (a) to (d) and write the SQL queries for (e) to (h) based
on the relations SCHOOL and ADMIN given below:

AMOGH BIYAL | XII-L


SCHOOL

COD TEACHER NAME SUBJECT DOJ PERIODS EXPERIENCE


E
1001 UMA SHANKAR ENGLISH 12/03/2000 24 10

1009 NANDITA RAI PHYSICS 03/09/1998 26 12

1203 LISA ANAND ENGLISH 09/04/2000 27 5

1045 YASHRAJ MATHS 24/08/2000 24 15


1123 JEEVAN PHYSICS 16/07/1999 28 4
1167 HARISH B CHEMISTR 19/10/1999 27 5
Y
1215 RAMESH PHYSICS 11/05/1998 22 16

ADMIN

CODE GENDER DESIGNATION


1001 MALE VICE PRINCIPAL
1009 FEMALE COORDINATOR
1203 FEMALE COORDINATOR
1045 MALE HOD
1123 MALE SENIOR TEACHER
1167 MALE SENIOR TEACHER
1215 MALE HOD

a) SELECT TEACHERNAME,PERIODS FROM SCHOOL WHERE PERIODS < 25


ORDER BY TEACHERNAME;
Output:

b) SELECT TEACHERNAME, ADMIN.CODE, GENDER FROM SCHOOL, ADMIN


WHERE SCHOOL.CODE = ADMIN.CODE AND GENDER LIKE 'FEMALE';
Output:

AMOGH BIYAL | XII-L


c) SELECT TEACHERNAME,DESIGNATION FROM SCHOOL, ADMIN WHERE
SCHOOL.CODE = ADMIN .CODE AND SUBJECT LIKE 'ENGLISH';
Output:

d) SELECT SUBJECT, PERIODS FROM SCHOOL GROUP BY SUBJECT HAVING


MIN(PERIODS);
Output:

e) Display Code, Teachers name , Designation and experience from school table and admin
table whose experience is more than 10 years
Query:

AMOGH BIYAL | XII-L


f) Add the details of a new teacher in school table . Details are as follows
(1011,VEENA, COMPUTER SCIENCE,12/07/2000,25)
Query:

g) To remove the details of all HODs from the ADMIN table


Query:

h) Increase the number periods by 2 for all the teachers handling PHYSICS
Query:

AMOGH BIYAL | XII-L

You might also like