Professional Documents
Culture Documents
DBAssignment
DBAssignment
DBAssignment
FROM Student s
FROM Student
FROM Enrolled e
3. SELECT name
FROM Class
FROM Enrolled
GROUP BY cname
5. SELECT fname
FROM Faculty
WHERE NOT EXISTS (
SELECT DISTINCT room
FROM Class
WHERE room NOT IN (
SELECT DISTINCT room
FROM Class
JOIN Faculty ON Class.fid = Faculty.fid
)
);
6. SELECT fname
FROM Faculty
WHERE fid IN (
SELECT f.fid
FROM Class AS c
GROUP BY f.fid
);
FROM Student
GROUP BY level;
8. SELECT level, AVG(age) AS average_age
FROM Student
GROUP BY level;
FROM Faculty
GROUP BY Faculty.fname
FROM (
FROM Student
GROUP BY St_Name
) AS class_counts
WHERE num_classes = (
SELECT MAX(num_classes)
FROM (
FROM Enrolled
GROUP BY student_id
) AS max_counts
);
Q2:
Q3:
a)
-> The given table satisfies the requirements of 1NF since each column contains atomic
values, and there are no repeating groups.
->In the given table, both "EmpID" and "TrainerID" together form the composite primary
key. "Training" and "Score" are dependent on this composite key. Therefore, the table
meets the requirements of 2NF.
However, it does not satisfy 3rd Normal Form (3NF) The table violates 3NF because the
attribute Training depends on a non-key attribute (TrainerID), which itself depends on
the primary key (EmpID).
b)
To normalize the table up to Boyce-Codd Normal Form (BCNF), we need to eliminate the
transitive dependency by decomposing the table.
TrainerTraining
TrainerID Primary Key
Training
Score
In the EmpTrainer table, EmpID is the primary key, and TrainerID is a foreign key
referencing the TrainerID in the TrainerTraining table.
Now both tables are in BCNF. EmpTrainer table has a single candidate key (EmpID) and
TrainerTraining table has a single candidate key (TrainerID).