Fundamental of Data Science Assignment Reformatted
Fundamental of Data Science Assignment Reformatted
Q1: Normalize the following unnormalized table "Orders" to the second normal form (2NF). Identify
the functional dependencies and primary key.
Unnormalized Table: Orders
Functional Dependencies:
1. Order_id -> Cust_Name, Cust_City
2. Product_id -> Product_Name
3. Order_id, Product_id -> Quantity
2NF Tables:
Orders (Order_id, Cust_Name, Cust_City)
Primary Key: Order_id
Q2: Consider two tables, "students" and "courses," with a common column "student_id." Write an
SQL query to retrieve the names of students who have not chosen courses.
SQL Query:
SELECT s.student_name
FROM students s
LEFT JOIN courses c ON s.student_id = c.student_id
WHERE c.course_id IS NULL;
Q3: Normalize the following unnormalized table "Employees" with columns: employee_id (primary
key), employee_name, department, and department_location. Normalize the table to the third
normal form (3NF).
Unnormalized Table: Employees
Emp_id Emp_name Dept Dept_location
Functional Dependencies:
1. Emp_id -> Emp_name, Dept, Dept_location
2. Dept -> Dept_location
Primary Key: Emp_id
Q4: If we have two tables, Student1 and Student2. Perform union, intersection, and difference
operations on Student1 and Student2.
Student1:
SID SNAME
S01 XYZ
S02 PQR
S03 ABC
Student2:
SID SNAME
S01 XYZ
S05 LMN
S06 DEF
SID SNAME
S01 XYZ
S02 PQR
S03 ABC
S05 LMN
S06 DEF
SID SNAME
S01 XYZ
SID SNAME
S02 PQR
S03 ABC
Q5: Solve the following query using relational algebra and SQL. Select the SID, SNAME from the
StudentXYZ table whose marks are greater than or equal to 90. Write the query and result.
StudentXYZ:
S01 XYZ 99
S02 PQR 95
S03 ABC 89
S04 LMN 88
S05 AZQ 90
Relational Algebra:
Marks >= 90 (StudentXYZ)
SQL Query:
SELECT SID, SNAME
FROM StudentXYZ
WHERE Marks >= 90;
Result:
SID SNAME
S01 XYZ
S02 PQR
S05 AZQ
Q6: Solve the following query using SQL. Select the SID, SNAME from the StudentXYZ table whose
marks are greater than or equal to 90, SID must be in ascending order, and SNAME must be in
descending order. Write the query and result.
StudentXYZ:
S01 XYZ 99
S01 ABC 85
S02 PQR 95
S03 ABC 89
S04 LMN 88
S02 ADC 84
S05 AZQ 90
SQL Query:
SELECT SID, SNAME
FROM StudentXYZ
WHERE Marks >= 90
ORDER BY SID ASC, SNAME DESC;
Result:
SID SNAME
S01 XYZ
S02 PQR
S05 AZQ