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

Sample_questions_MidSem_DBMS.docx

ghghhhgjghh

Uploaded by

Shubham Karn.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Sample_questions_MidSem_DBMS.docx

ghghhhgjghh

Uploaded by

Shubham Karn.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

Create tables named student, marks with the following fields:


Student:
Field Data type Constraint
Sno number(10) primary Key
Sname varchar(15) not null
Sclass varchar(10) default II CSE A
Sdob date
Scity varchar(15)

Marks:
Field Data type Constraint
Sno number (10) foreign key referring to Sno of student
Mark1 number (3) check !>100, default 0
Mark2 number (3) check !>100, default 0
Mark3 number (3) check !>100, default 0

Create a new relation or alter the existing relation based on the requirements given.
a. Display the student’s no, name, and their marks.
b. Compute and display the total marks, average of the students along with their roll no
name.
c. Display the student details no, name, marks irrespective to enrollment to exam.
d. Display the student sno, sname, representative id, and representative name.
e. Display the student sno, name, course_id, course_name irrespective to students’
admission in a course.
f. Display all student and course details.
2.Create tables named employee, department with the fields given below:
Employee:
Field Data type Constraint
Eno number(10) primary key
Ename varchar(15) not null
EDept varchar(10) foreign key
Edoj date
Esalary number(7)
Ecity varchar(15) default ‘sathy’
Ephone number unique
Department:
Field Data type Constraint
Dno number primary key
Dname varchar(15) unique
Dmgr number foreign key
a. Find the youngest employee in the work place (Based on work experience).
b. Display the detail of employees who are not belonging to sales dept.
c. Create a View named emp_mgr with the attributes eno, ename, and edept which store the
employee details who are manager. The data for the view can be derived from the base
table employee. Alter the base table as per the requirements.
o Display the contents of the View.
o Perform the insertion, deletion, and update operations in the View and check the base
table for the update.
3.Create tables named book, client with the fields given below:
Book:
Field Data type Constraint
Bno number(10) primary key
Btitle varchar(15) not null, unique
Bauthor varchar(10)
Bprice number check <= Rs.0

Client (Borrower):
Field Data type Constraint
Cno number(10) primary key
Cname varchar(15) not null
Caddress varchar(10) default ‘Coimbatore’
Bno number foreign key
Perform Join operations:
Note: Create a new relation or alter the existing relation based on the requirements given
a. Update the price of all books by adding Rs. 10 to their current prices.
b. Find the total number of books borrowed by clients.
c. Calculate and display the average price of books for each author.
d. Display the client name, book title, and author for clients who have borrowed books.
e. Display the names of clients who have borrowed books with a price greater than Rs. 50.

4.Create tables named customer, and account with the fields given below:
Customer:
Field Data type Constraint
Cno number(10) primary key
Cname varchar(15) not null
Cage number
Ccity varchar(15) default ‘sathy’
Cphone number unique
Account
Field Data type Constraint
Ano number(10) primary key
Balance number(10) check < Rs 500
Cno number foreign key

Perform Join operations


Note : Create a new relation or alter the existing relation based on the requirements given.
a. Display the customer no, name, acc-no, balance amount in that account hold by the
customer.
b. Display the customer name, account number, and balance for customers who have
accounts.
c. Calculate the average age of all customers.
d. Add a new field named "Email" to the "Customer" table to store customer email
addresses.
e. Create a new table named "Loan" with fields "LoanID" (as primary key), "LoanAmount,"
and "Cno" as a foreign key referencing the "Customer" table. Insert a loan record for a
customer with a loan amount of Rs 10,000. Then, display the customer name, loan ID,
and loan amount for customers with loans.

5.Create tables named employee, department with the fields given below:
Employee:
Field Data type Constraint
Eno number(10) primary key
Ename varchar(15) not null
EDept varchar(10) foreign key
Edoj date
Esalary number(7)
Ecity varchar(15) default ‘sathy’
Ephone number unique
Department:
Field Data type Constraint
Dno number primary key
Dname varchar(15) unique
Dmgr number foreign key

Perform Join operations


Note : Create a new relation or alter the existing relation based on the requirements given.
a. Display the employee number, employee name, department number, and department
name for employees working in a department.
b. Calculate the average salary for each department and display details in sorted order
based on department.
c. Add a new field named "Location" to the "Department" table to store the location of
each department (e.g., 'Headquarters,' 'Branch A'). Then, display the names of
employees along with their department names and locations.
d. Find the highest salary among all employees and display the employee's number,
name, and the salary.
6. Create tables named book, client with the fields given below:
Book:
Field Data type Constraint
Bno number(10) primary key
Btitle varchar(15) not null, unique
Bauthor varchar(10)
Bprice number check <= Rs.0

Client:
Field Data type Constraint
Cno number(10) primary key
Cname varchar(15) not null
Caddress varchar(10) default ‘sathy’
Bno number foreign key
a. Update the salary of all employees in the 'HR' department to Rs 70000.
b. Display the employee number, employee name, department number, and department
name for employees working in a department.
c. Display the book’s title start with letter ‘S’ / end with letter ‘A’
d. Use any 3 Date functions used in SQL
e. Create a View named book_author with the attributes bno, btitle, and author. The
data can be derived from the base table book.
● Display the contents of the View.
● Perform the insertion, deletion, and update operations in the View and check the
base table for the update.
7.Create tables named customer, account with the fields given below:
Customer:
Field Data type Constraint
Cno number(10) primary key
Cname varchar(15) not null
Cage number
Ccity varchar(15) default ‘sathy’
Cphone number unique
Account:
Field Data type Constraint
Ano number(10) primary key
Balance number(10) check < Rs 500
Cno number foreign key

a. Find the average age of the customers of the organisation


b. Display the customer's name, age, city, and their account balance.
c. Display the names and ages of customers who have an account balance greater than
Rs. 200.
d. Create a View named cus_address with the attributes cno, cname, ccity, and phone.
The data can be derived from the base table customer.
● Display the contents of the View.
● Perform the insertion, deletion, and update operations in the View and check the
base table for the update
ER Diagram

1. Construct an E-R diagram for a car-insurance company whose customers own one or more
cars each. Each car has associated with it zero to any number of recorded accidents.
2. Construct an E-R diagram for a hospital with a set of patients and a set of medical doctors.
Associate with each patient a log of the various tests and examinations conducted.
3. Draw the E-R diagram which models an online bookstore.
4. Draw the E-R diagram which models an University database.Identify the possible entities and
relation.
5. Comstruct an E-R diagram for the Bank database.

You might also like