III. Query questions. (COVERING 12 ITEM, 67 marks IN TOTAL)
Table:Movies
Id Title Director Year Length_minutes
1 Toy Story John Lasseter 1995 81
2 A Bug's Life John 1998 95
3 Toy Story 2 John Lasseter 1999 93
4 Monsters, Inc. Pete Docter 2001 92
5 Finding Nemo Andrew Stanto 2003 107
7 Cars John Lasseter 2006 117
9 WALL-E Andrew Stanton 2008 104
10 Up Pete Docter 2009 101
11 Toy Story 3 Lee Unkrich 2010 103
12 Cars 2 John Lasseter 2011 120
13 Brave Brenda Chapman 2012 102
87 WALL-G Brenda Chapman 2042 97
Table: Boxoffice
Movie_id Rating Domestic_sales International_sales
5 8.2 380843261 555900000
12 6.4 191452396 368400000
3 7.9 245852179 239163000
9 8.5 223808164 297503696
11 8.4 415004880 648167031
1 8.3 191796233 170162503
7 7.2 244082982 217900167
10 8.3 293004164 438338580
4 8.1 289916256 272900000
2 7.2 162798565 200600000
13 7.2 237283207 301700000
1. Create the table Movies. It includes the domain of values associated with each attribute and integrity constraints. (7 marks)
2. Write an SQL query that finds the title of each film.(5 marks)
3. Write an SQL query that finds the movies released in the years between 2000 and 2010 . (5 marks)
4. Find all the WALL-* movies. (5 marks)
5. List the last four Pixar movies released (ordered from most recent to least). (5 marks)
6. Find the domestic and international sales for each movie. (6 marks)
7. List all movies that were released on even number years. (5 marks)
8. Add the studio's new production, Toy Story 4 to the list of movies (you can use any director). (5 marks)
9. The director for A Bug's Life is incorrect, it was actually directed by John Lasseter. (5 marks)
10. This database is getting too big, lets remove all movies that were released before 2005. (5 marks)
11. SELECT title, year FROM movies WHERE year < 2000 OR year > 2010; (6 marks)
Write the result:
a) Create a data sheet in MS Access which includes Employee ID, Employee Name, Father Name, Gender (Male, Female), Age, Date of Joining (dd-mm-yyyy), Address, Cell number (0300-0000000) and City (Karachi, Islamabad, Lahore).
b) Also create its Form and add at least 2 record through the form and create the following queries:
· List only those employees who belong to the city Karachi.
· Show only the female employee in the employee table
There should be at least 12 to 15 record in the table.
Please reply as early as possible.
what do you think that what will the role of a database system for business in the future?
TOPIC: SQL Stored procedures:
S_ID
101
201
301
401
501
601
Name
Ella
Christian
Sofia
Lillian
John
Joseph
Gender
F
M
F
F
M
M
City
California
Texas
Arizona
Maryland
California
Hawaii
Attendance %
69
88
68
82
60
72
Quiz 1 (10)
5
6
5
6
7
8
Quiz 2 (10)
8
7
2
3
5
6
Quiz 3 (10)
6
7
5
4
8
Assign 1(10)
5
5
8
5
9
5
Assign 2 (15)
12
11
10
9
8
14
Assign 3 (10)
7
6
3
7
6
4
Final (45)
34
43
26
34
41
22
T_ID CourseName S_ID
1101 Digital marketing 101
1102 AI and data science. 301
1103 Web development 401
1104 Cyber Security. 201
CASE: The above tables are extracted an examination department of an institution. The examination department wants to have a consolidated total of students’ scores in each subject, where, the weightage of quizzes, assignments and attendance are 25%, 35% and 5% respectively. The remaining weightage belongs to the final term result. Also, they requested the IT department for a procedure which generates Letter Grades and respective Grade Points (as mentioned in the table below). As the institution has many campuses over the country, they also need to have a City-wise students’ progress for campus-wise comparison.
Marks Grade Points
88-100 A. 4
81-87. B+ 3.5
74-80. B. 3
67-73. C+ 2.5
60-66. C 2
Below 60 F. 0
Q.4. Answer the following as SQL queries. Also write corresponding relational algebra expression: (15 marks) a. Number of rakats prayed as Qaza by each person b. How many females have skipped fajar salah on 1st shawwal c. How many salah are missed by Mr. Noman d. Average time M. Noman takes for praying Isha Salah e. Which salah is missed mostly by M. Saleem f. Which salah is missed the second most by all people
Q.4. Answer the following as SQL queries. Also write corresponding relational algebra expression: (15 marks)
a. Number of rakats prayed as Qaza by each person
b. How many females have skipped fajar salah on 1st shawwal
c. How many salah are missed by Mr. Noman
d. Average time M. Noman takes for praying Isha Salah
e. Which salah is missed mostly by M. Saleem
f. Which salah is missed the second most by all people
An array A[0..n-1] is sorted using the merge-sort algorithm. The worst case and the best case running time of this computation respectively are
Q.4. Answer the following as SQL queries. Also write corresponding relational algebra expression:
a. Number of rakats prayed as Qaza by each person
b. How many females have skipped fajar salah on 1st shawwal
c. How many salah are missed by Mr. Noman
d. Average time M. Noman takes for praying Isha Salah
e. Which salah is missed mostly by M. Saleem
f. Which salah is missed the second most by all people
Q.2. Suppose, for a Salat management system, you have the following information: (10 marks)
Person Name, Gender , Age, Date, Time, Prayed Rakats, Ontime/Offtime, Time to pray
a. Identify the associated updation/deletion anomalies if the data is stored as it is in a single table
b. Identify functional dependences/ transitive dependencies that can be used to normalize
c. Normalize the database into constituent tables