Bahria University: Lahore Campus
Bahria University: Lahore Campus
Lahore Campus
Mid Term Exam
(Spring-2021 Semester)
Department of Computer Sciences
Instructions:
Read out the Instructions carefully.
I. Attempt all questions
II. Copying from any source will be graded as zero
Question 1 15 Marks
Consider the following relations
A. Movie (movieTitle, year, length, director)
B. Stars (sid, name, age, rating, salary)
C. Producer (name, address, gender, startingYear)
D. Region (rid, movieRegion, address)
E. Studio (studioName, address)
Solution
CREATE DATABASE LAB_MID
insert into MOVIE values ('Inception', 2010 ,'2 HOUR', 'CHRISTOPER NOLN' ),
('Extraction', 2020 , '1 HOURS' , 'Mike Larocca' ),
('The Matrix',1999,'3 HOUR','Joel Silver');
insert into PRODUCER values ('HAWARD HAWKS', 'STREET # 123 CALIFORNIA' , 'MALE' , 1994),
('HANK MOODY' , 'CALIFORNICATIN' ,'MALE',2007),
('KATHRYN ANN BIGELOW','SAN CARLOS , UNITED STATE' , 'FEMALE' , 1989);
--1
select name from STARS
--2
--3
select * from movie
where movieTITLE = 'BOSS BABY';
--4
select age from stars order by age
--5
--6
--7
--8
--9
--10
sp_rename 'stars','Star';
--11
sp_rename 'star.age','star_age';
--12
select name, salary from star where salary > 50000;
--13
--14
--15
Screenshots
Question 2 (7 Marks)
);
--1
select distinct name from employee
--2
--3
--4
--5
--6
UPDATE department
SET BUDGET = budget + BUDGET*10/100;
--7
update employee
set DEPARTMENT='Computer' where DEPARTMENT='Biology';
Screenshot
Question 3 Write SQL statements for: (8 Marks)
1. Create a table student with columns and data types: rollno int, name varchar(20), branch varchar(20);
2. Insert suitable data into the student table
3. Alter table by adding new column class varchar(20)
4. Deleting a row from the table
5. Drop column branch
6. Alter table by changing the data type of rollno to nvarchar(8).
7. Delete all the data from student table.
8. Delete the table.
Solution
--1
--3
--4
--5
--6
--7
--8
Screenshot