Name: Date:
Instructions: Answer Section A in your own words. For Section B circle one answer per question. Complete Section C using SQL and JDL, with explanations where requested. Extra paper may be used for longer answers.
14 questions. Answer in your own words.
A1. What is a database? Give one example of how a university might use one. [2 marks]
A2. What is a Database Management System (DBMS)? Explain two benefits of using one instead of separate spreadsheets. [3 marks]
A3. Explain the difference between a database schema and the actual data stored in a database. [2 marks]
A4. What are entities, attributes and relationships in an ER model? Give one example of each. [3 marks]
A5. Explain the difference between a primary key and a foreign key, using a Student and Module database as an example. [3 marks]
A6. Explain the differences between one-to-one, one-to-many and many-to-many relationships. Give an example of each. [3 marks]
A7. Why is a junction table needed for a many-to-many relationship in a relational database? [2 marks]
A8. What is database normalisation, and why is it useful? [3 marks]
A9. State the requirements of First Normal Form (1NF). [2 marks]
A10. What extra requirement does Second Normal Form (2NF) introduce? Explain what a partial dependency is. [3 marks]
A11. What is a transitive dependency? Explain why Third Normal Form (3NF) aims to remove it. [3 marks]
A12. Explain the difference between an INSERT anomaly, UPDATE anomaly and DELETE anomaly. [3 marks]
A13. What does CRUD stand for? Give the SQL command associated with each operation. [2 marks]
A14. What is the difference between SQL commands and psql commands? Give one syntactic distinction. [1 marks]
15 questions × 2 marks. Circle exactly one answer (A, B, C or D).
B1. Which statement best describes a database schema? [2 marks]
B2. Which is a key benefit of a DBMS? [2 marks]
B3. In an ER model, StudentID is most naturally an example of: [2 marks]
B4. A lecturer teaches several modules, each with one lecturer. The relationship is: [2 marks]
B5. Where is the foreign key normally placed in a one-to-many relationship? [2 marks]
B6. How is a many-to-many relationship normally implemented in relational tables? [2 marks]
B7. Which issue violates First Normal Form (1NF)? [2 marks]
B8. What does Second Normal Form (2NF) eliminate? [2 marks]
B9. Which best describes a transitive dependency? [2 marks]
B10. A student's deletion also removes the only stored record of a class. This is: [2 marks]
B11. Which statement about a primary key is correct? [2 marks]
B12. Which SQL command retrieves records from a table? [2 marks]
B13. What happens when DELETE FROM students; executes successfully without a WHERE clause? [2 marks]
B14. Which statement is a psql meta-command rather than a SQL command? [2 marks]
B15. In JDL, what does relationship ManyToMany describe? [2 marks]
Five questions: two fill-in-the-blanks, two code reasoning tasks and one extended Instate/JDL task.
Complete the statement to create a table named Student with a unique, non-null integer student_id as its primary key and a text name.
CREATE _____ Student (
student_id INTEGER _____ _____,
name _____,
PRIMARY KEY (_____)
);Complete the JDL for Student and Module. Each student can enrol in many modules, and each module can contain many students.
entity Student {
name _____ required
}
entity Module {
title _____ required
}
relationship _____ {
Student{_____} to Module{_____}
}The command below is intended to delete only the student with ID 7. Explain the problem, give the corrected SQL and describe the danger of running the original command.
DELETE FROM student;
A table called Module contains (1, 'Databases'), (2, 'Web Programming') and (3, 'AI'), with columns module_id and title. What does this query return? Explain SELECT and WHERE.
SELECT title FROM Module WHERE module_id = 2;
Write a JDL model for Student (name String required, email String required unique), Module (title String required, credits Integer required) and Lecturer (fullName String required). A student can enrol in many modules; a module can have many students. One lecturer teaches many modules; each module has one lecturer. Include useful navigation names. Explain which tables and foreign keys you expect from JHipster. Test the JDL at https://instate.shah.fyi/jdl if you wish.
// Write your full JDL model in the space below.