0% found this document useful (0 votes)
23 views10 pages

DBMS Lab Assignment 2

The document outlines a lab assignment focused on database operations including identifying objects, attributes, and constraints. It includes a series of SQL commands for inserting, deleting, and modifying records in various tables such as EMPLOYEE, PROJECT, and DEPARTMENT, as well as queries for retrieving specific employee information. Additionally, it discusses integrity constraints and differences in SQL query operations.

Uploaded by

Hrishika
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)
23 views10 pages

DBMS Lab Assignment 2

The document outlines a lab assignment focused on database operations including identifying objects, attributes, and constraints. It includes a series of SQL commands for inserting, deleting, and modifying records in various tables such as EMPLOYEE, PROJECT, and DEPARTMENT, as well as queries for retrieving specific employee information. Additionally, it discusses integrity constraints and differences in SQL query operations.

Uploaded by

Hrishika
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/ 10

LAB ASSIGNMENT 2:

23C4130
Ques 1: Identifying Database Objects,Attributes and constraints.
Attributes are under Field column, their data type in second.Constraint=NULL,KEY,DEFAULT.
Ques 3:
a. Insert <‘Robert’, ‘F’, ‘Scott’, ‘943775543’, ‘1972-06-21’, ‘2365 Newcastle Rd, Bellaire, TX’, M,

58000, ‘888665555’, 1> into EMPLOYEE.


b. Insert <‘ProductA’, 4, ‘Bellaire’, 2> into PROJECT.

Dnumber=2 doesn’t exist.

c. Insert <‘Production’, 4, ‘943775543’, ‘2007-10-01’> into DEPARTMENT.

d. Insert <‘677678989’, NULL, ‘40.0’> into WORKS_ON.

e. Insert <‘453453453’, ‘John’, ‘M’, ‘1990-12-12’, ‘spouse’> into DEPENDENT.


f. Delete the WORKS_ON tuples with Essn = ‘333445555’.

g. Delete the EMPLOYEE tuple with Ssn = ‘987654321’.

h. Delete the PROJECT tuple with Pname = ‘ProductZ’.


i. Modify the Mgr_ssn and Mgr_start_date of the DEPARTMENT tuple with Dnumber = 5 to
‘123456789’ and ‘2007-10-01’, respectively.

j. Modify the Super_ssn attribute of the EMPLOYEE tuple with Ssn =‘999887777’ to
‘943775543’.

k. Modify the Hours attribute of the WORKS_ON tuple with Essn =‘999887777’ and Pno = 10 to 5.0.
L . Retrieve the names of all employees in department 5 who work more than 10 hours per
week on the ProductX project.

m. List the names of all employees who have a dependent with the same first name as
themselves.

NONE EXIST
n. Find the names of all employees who are directly supervised by ‘Franklin Wong’.

o. Retrieve the name and address of all employees who work for the ‘Research’ department.

p. For every project located in ‘Stafford’, list the project number, the controlling department
number, and the department manager’s last name, address, and birth date.

q.dbt
For each employee, retrieve the employee’s first and last name and the first and last name of hisor her
immediate supervisor.
r. Make a list of all project numbers for projects that involve an employee whose last name is
‘Smith’, either as a worker or as a manager of the department that controls the project.

s. Retrieve all employees whose address is in Houston, Texas.

t. Find all employees who were born during the 1950s.

u.Show the resulting salaries if all employees working on ProductX are given a 10% raise.

v. Retrieve the names of all employees who do not have supervisors.


Superssn=null doesn’t give correct result
w. Retrieve the name of each employee who has a dependent with the same first name and is
the same sex as the employee.
mst 1:queries
select fname from employee where bdate like ‘199%’;
select fname from employee where bdate between ‘1990-01-01’ and ‘1990-12-31’;
where year(bdate) between 1990 and 1999

query :not manager


diff between except and not in?

except(duplicated allowed),left join,not in(duplicated not allowed)


query:
select fname,lname from employee where ssn in (select ssn from employee except select mgrssn from
department);

or

select fname,lname from employee where ssn not in (select mgrssn from department);

integrity constraints are set of rules on attributes to maintain integrity of data.

q1 5.tell on both column level and table level.

foreign key(attribute name) datatype references basetablename(attribute)


on delete<cascade/setdefault/setnull>
on update<cascade/set….>

You might also like