Practice Flashcards
What are the three database schema levels?
Track your progress — Sign up free to save your progress and get smart review reminders based on spaced repetition.
All Flashcards in Topic 3.2
Below are all 35 flashcards for this topic. Sign up free to track your progress and get personalized review schedules.
3.2.15 cards
What are the three database schema levels?
Conceptual — the entities and relationships the organisation cares about. Logical — those turned into tables, columns, keys and data types. Physical — how the chosen system actually stores it, including files and indexes.
What does a conceptual schema contain, and what does it leave out?
It contains the entities and the relationships between them, in language the organisation recognises. It deliberately omits keys, data types and any choice of database product.
What belongs to the physical schema?
How the chosen system stores the data: files on disk, indexes, partitions and storage settings. This is where performance decisions live, and it must be redone if you change database product.
What is data independence?
The schema levels are insulated from each other, so a change at one does not force a change at another. Adding an index at the physical level alters no query written against the logical schema.
Why describe one database three times?
So the meaning can be agreed with non-technical people before technical choices are made, so storage can change without breaking programs, and so the same logical design can be built on different database systems.
3.2.25 cards
What does an ERD show?
The entities a database stores and the relationships between them. Each box is one kind of thing that will become a table; each line is a relationship, labelled with the verb joining them.
What is the difference between cardinality and modality?
Cardinality is how many — one or many, drawn as a bar or a crow's foot. Modality is whether the relationship is compulsory — mandatory drawn as a second bar, optional as a circle.
How do you work out a relationship's cardinality?
Say it as a sentence in both directions. 'A teacher teaches many classes' and 'a class is taught by one teacher' together give one-to-many, with the crow's foot on the Class end.
Why must a many-to-many relationship be resolved?
A column holds only one value, so neither table can hold several foreign keys. It is replaced by a linking entity with one row per pair, keyed on both foreign keys together.
Where does the foreign key go in a one-to-many relationship?
In the table on the many side. A Class holds TeacherID, because the alternative would need a Teacher row to hold an unknown number of class columns.
3.2.35 cards
What does a column's data type do?
It says what kind of value may be stored, and the database refuses anything that does not fit. It also decides what can be done with the values — arithmetic on numbers, true ordering on dates.
How do you decide a column's data type?
Ask whether you will ever calculate with it, compare it, or sort it. If yes it needs a real type; if it is only ever displayed — a phone number or postcode — text is correct however numeric it looks.
Why store a phone number as text rather than a number?
A numeric type drops the leading zero, so 07700 becomes 7700, and no arithmetic is ever done on a phone number anyway.
What three things go wrong if a date is stored as text?
Sorting compares character by character so the order is wrong; date ranges and age calculations become impossible; and nothing rejects an impossible date such as 31/02/2026.
Why must a foreign key have the same data type as the primary key it references?
Otherwise the join either fails or silently returns nothing — values that look equal to a person are not equal to the database when their types differ.
3.2.45 cards
How do you turn an ERD into tables?
Each entity becomes a table and each relationship becomes a foreign key. In a one-to-many the foreign key goes in the many table; a many-to-many needs a linking table holding both foreign keys.
Why does the foreign key go in the many table?
Because a column holds one value. A Class row holds one TeacherID easily, whereas a Teacher row would need an unknown number of columns to hold every class they take.
What is the difference between a composite key and a concatenated key?
A composite key uses two or more columns together as the primary key, keeping them separate and queryable. A concatenated key glues values into a single column, such as 2026-S1, which then has to be pulled apart to filter on either part.
What are entity, referential and domain integrity?
Entity integrity: a primary key is never empty or duplicated. Referential integrity: a foreign key must match an existing row. Domain integrity: a value must fit its column's data type.
Why enforce rules in the database rather than in the program?
Rules enforced by the database apply to every program that touches the data, including ones written years later. Rules enforced in a program apply only to that program.
3.2.55 cards
What is a functional dependency?
One column's value determining another's. Knowing a StudentID tells you the student's name, so Name is functionally dependent on StudentID. Normal forms are rules about which dependencies are allowed where.
What do 1NF, 2NF and 3NF each require?
1NF: every cell holds one value and every row is uniquely identified. 2NF: no non-key column depends on only part of a composite key. 3NF: no non-key column determines another non-key column.
What is a partial-key dependency?
A non-key column depending on only part of a composite primary key. With a key of StudentID and Club, StudentName depends on StudentID alone. It can only arise when the key is composite.
What is a transitive dependency?
A non-key column determining another non-key column. Club determines Teacher and Teacher determines Room, so Room depends on Club only indirectly — which breaks 3NF.
Why normalise, beyond saving space?
To prevent update problems, where one copy of a repeated fact is changed and others are not; insert problems, where a new club with no members has nowhere to live; and delete problems, where removing the last member loses the club's details too.
3.2.65 cards
What are the four steps to normalise a design to 3NF?
List every piece of data with sample rows; make cells atomic and choose the key; move out anything depending on part of a composite key; move out any non-key column determined by another non-key column.
Why write sample rows before normalising?
Because functional dependencies are far easier to see in actual data than in a list of column names — repeated values make the repeated facts visible.
How do you find a transitive dependency?
In each table ask whether any non-key column determines another non-key column. If so, both move to a new table, and the determining column stays behind as a foreign key.
How do you check a finished 3NF design?
Pick a fact the scenario needs and follow the keys to find it. If you cannot reach it, a link is missing; if you find it in two places, the design is not yet in 3NF.
How many tables should a typical scenario produce?
More than feels natural — a scenario with eight columns usually becomes about four tables. Finishing with one or two almost always means a transitive dependency was missed.
3.2.75 cards
What is denormalisation?
Deliberately storing some data more than once so that reads need fewer joins and run faster. It is a considered engineering trade, not a mistake.
What does denormalising gain and what does it risk?
It gains faster reads and simpler queries. It risks the same fact being stored in two places and disagreeing, requires every update to find every copy, and brings back insert and delete problems.
When is denormalising justified?
When data is read far more often than it is written — reports, dashboards and data warehouses that are loaded in bulk and then only read. Never for frequently-written data such as bookings or stock levels.
How should the risk of denormalising be managed?
Keep the normalised tables as the authoritative source and rebuild the denormalised copy from them, so there is always one correct version to fall back on.
Why should you normalise before denormalising?
Because you should design in 3NF, run it, and find out where it is actually slow. Denormalising before a measured problem exists gives away correctness for a speed gain you cannot demonstrate.
Topic 3.2 study notes
Full notes & explanations for Database design
Computer Science exam skills
Paper structures, command terms & tips
Want smart review reminders?
Sign up free to track your progress. Our spaced repetition algorithm will tell you exactly which cards to review and when.
Start Free