Lab 5 Declarative Programming
Lab 5 Declarative Programming
1. Write a SQL lites statement to create a table names as employees including columns
employee_id, first_name, last_name, email, phone_number hire_date, job_id, salary,
commission, manager_id and department_id
i) Insert values in the table and also execute the table structure
ii) Display the first name, last name of an employees whos salary is greater than
25,000
2. Create a table for Student with the following fields (Reg_no,stud_name,sex, and create a
table Dept with the following fields(dept_no primary key, dept_name)
a. Insert sample records and do the following
b. Display the student reg_no,name and dept_name
c. Display the student names ending with ‘ka’
d. Display all the female students name
e. Display the student names by descending order
3. Create the below table and execute the insert, update and the below select statements.
i) Write a query to display the total number of recipes available with the description
“Chinese”
ii) Write a query to display the id, name of the recipes with chef_id 'BL000002'.
iii) Write a query to display the description of the recipes whose name begins with 'P'.
4. Using the built in sqlite3 database, write a python script to create a table movie of the
below structure and assume data types. Movie_ID, Movie_Name, Genre, Language,
Rating , Do the following queries
a. Update the movies rating by 10% and display it
b. Delete the movies with movie_id 102
c. Select movies whose rating is more than 3.
5. Using sqlite3, Create a course database with the following fields Product(ID, Prod_name,
Supplier_id,Unit_price,Package,OrderID)
,OrderItem(ID,Order_id,Product_id,Unit_price,Quantity) using Foreign key
a. Display the total quantity of every product in the stock
b. Sort the Unit_price based on the supplier_id
c. Display the Product_name along with order_id and supplier_id
7. Write a SQL lite3 statement to create a table named as job including columns
job_id,job_title,Min-salary,Max_salary. job_id column does not contain any duplicate
value at the time of insertion
8. Write a SQL lite3 statement to create a table names as job_history including columns
employee_id, start_date, end_date, job_id and department_id and make sure that, the
employee_id column does not contain any duplicate value at the time of insertion and the
foreign key column job_id contain only those values which are exists in the jobs table.