AQA A2 Computing 5.2 Database Design Flashcards
Relation
Aset of attributes and tuples, modelling an entity (a table)
Attribute
A property or characteristic of an entity (a named column in a table)
Tuple
A set of attribute values (a row in a table)
Primary Key
An attribute which uniquely identifies a tuple
Relational Database
A collection of tables
Composite Key
A combination of attributes that uniquely idetify a tuple
Foreign key
An attribute in one table that is a primary key in another table(used to form a link between tables)
Referential integrity
If a value appears in a foreign key in one table, it must also appear in the primary key in another table
Normalised entities
a set of entities that contain no redundant data
Normalisation
A technique used to produce a normalised set of entries
1NF
Atomic data test
A relation is in 1NF if it contains no repeating groups
To convert an unnormalised relation to 1NF either:
Flatten the table and change the primary key, or
Decompose the relation into smaller relations, one for the repeating groups and one for the non-repeating groups.
Remember to put the primary key from the original relation into both new relations.
This option is liable to give the best results.
Atomic data test
The table does not contain repeating groups of attributes
2NF
Partial key dependance test
A relation is in 2NF if it contains no repeating groups and no partial key functional dependencies
Rule: A relation in 1NF with a single key field must be in 2NF
To convert a relation with partial functional dependencies to 2NF. create a set of new relations:
One relation for the attributes that are fully dependent upon the key.
One relation for each part of the key that has partially dependent attributes
Partial Key dependance test
The data is wholly reliant on the primary key.
E.g. an order table which contains customer address would fail as the address is not dependant on the order number. This should be resolved by creating a customer table and linking the order with the customer number
3NF
Non-Key dependance test
A relation is in 3NF if it contains no repeating groups, no partial functional dependencies, and no transitive functional dependencies
To convert a relation with transitive functional dependencies to 3NF, remove the attributes involved in the transitive dependency and put them in a new relation
Rule: A relation in 2NF with only one non-key attribute must be in 3NF
In a normalised relation a non-key field must provide a fact about the key, the whole key and nothing but the key.
Relations in 3NF are sufficient for most practical database design problems. However, 3NF does not guarantee that all anomalies have been removed.