DBMS Lab 06
DBMS Lab 06
Task 1
Design a database system for a university. The university has multiple departments, each
offering several courses. Students enrol in courses offered by these departments. Professors
teach these courses. Each course has multiple assessments (exams, assignments, etc.), and
students receive grades for these assessments. Students may also belong to various clubs and
organizations within the university. Clubs organize events and have members.
• Create table for each entity and create attributes for each table also use appropriate
primary and foreign keys in tables where applicable.
• Enter data of 5 rows for each table using insert into statement
• Define tuple, relation, attributes, cardinality, and degree of a relation.
• Domain of each attribute of each entity
• Primary and foreign keys of a relation
A primary key uniquely identifies a tuple within a relation. It cannot be null and should have
minimal redundancy.
A foreign key references the primary key of another table, establishing a relationship between
them.
Task 2
Write a report on all steps taken to achieve the above task with screenshots of each
step and query code. The report must include how you were able to identify
entities, attributes, and relations.
01. Select all columns of a table
Select a Specific column of a table
Task 1: Create the below mentioned table using SQL and insert at least 10 records
in this table using insert into statement, also create primary key. After insertion
apply all above SQL variants on this table like
1. Select all data from the employee table
2. Select only employee_id and department from employee table
3. Select only those employee id where department is Finance
4. Select distinct departments from employee
5. Select hire date from employee in ascending order (order by clasue)
Task 2:
Research and describe the fundamental SQL commands used for data manipulation and
database management, namely UPDATE, DELETE, ALTER, DROP, and TRUNCATE.
For each command, provide its syntax and a brief explanation of its functionality.
Additionally, discuss under what circumstances you would use each command and
provide an example of its application, preferably using the existing employee’s table.
Lastly, if you needed to remove an entire database, which command among DROP,
DELETE, and TRUNCATE would be most appropriate, and why?
1. UPDATE:
3. ALTER TABLE:
4. DROP TABLE:
5. TRUNCATE TABLE:
• DELETE operates on tables within a database. You would need to run separate
DELETE statements for each table, making it inefficient for an entire database.
• TRUNCATE also works on individual tables. While faster than DELETE for a single
table, it's not suitable for removing the entire database structure.
• DROP DATABASE removes the entire database, including all its tables, data, and
associated objects. This is the most efficient and appropriate way to delete a database
you no longer need.
Remember: Use DROP DATABASE with extreme caution as it's a permanent action.