IBDP 11 – Database Programming
Practice WS (Aug 2025)
Question 1
Write the DDL statements for the following tasks.
1. Create a table Employee that has the following fields. Choose a suitable
datatype for the fields. Also, identify the suitable primary key for the table.
Establish foreign key relationship with the corresponding table.
a. Emp_ID
b. Emp_Name
c. DOJ
d. Department_ID (should be a foreign key from Department table)
e. Designation
f. Salary
2. Create a table Department that has the following fields. Choose a suitable
datatype for the fields. Also, identify the suitable primary key for the table.
a. Dept_ID
b. Dept_Name
c. Num_Employees
3. Alter the structure of Employee table to add a column DOL that will store the
date on which the employee has left the organization.
Question 2
Write DML statements to perform the following tasks
1. Insert the 2 records into Department table with following data
a. Department ID as D001 and Department Name as “Sales”
b. Department ID as D002 and Department Name as “Finance”
2. Insert 2 records into Employee table with values of your choice. One employee
should belong to Sales department and the other to Finance department.
3. Update the Employee table to change the existing salary amount to 50000 for
the employee from the Sales department.
4. “Delete From” is an SQL command used to delete one or more records from the
table.
Outline the result of this command when applied on Department table to
delete the record corresponding to “Finance” department.
Question 3
The database table PATIENTS stores the details of the patients. Part of the data is
given in the following table.
Analyse the table data and write the SQL statements that follow:
Patie name gend Bill_A contact City medical_hist P_Type
nt er mt ory
_id
1 John Male 26000 12345678 Delhi Diabetes, Inpatient
Doe 90 Hypertension
2 Jane Femal 12000 09876543 Punjab Asthma Inpatient
Smith e 21
3 Micha Male 1500 22233344 Chenn Hypertension Outpatient
el 44 ai
Scott
4 Pam Femal 50000 Mumb None Inpatient
Beesly e ai
5 Dwigh Male 3000 55566677 Chenn None Outpatient
t 77 ai
Schrut
e
6 Jim Male 54000 11122233 Delhi Back Pain Inpatient
Halper 33
t
Write SQL statements to perform the following tasks
a. To display all the details of female patients
b. To display the id and name of patients who has no medical history
c. To display the id, name and gender of the patients whose names starts
with the alphabet “J”
d. To display the details of the all the outpatients in the increasing order of
bill amount.
e. To display the id, name and gender of inpatients with bill amount ranging
from 10000 to 130000
f. To display the medical history of patients from Chennai