4 - 17 Relational Databases And Normalisation Flashcards
What is a relational database?
A relational database is a collection of tables in which relationships are modeled by shared attributes.
Describe the structure of a table in a relational database
One row of a table holds one record. Each column in the table represents one attribute.
Book (BOOKID, DeweyCode, Title, Author, DatePublished)
Which is the entity name, attributes and primary key
The entity name is shown outside the brackets
The attributes are listed inside the brackets
The primary key is normally underlined but in CAPS in this case.
What is a primary key?
The primary key is composed of one or more attributes that uniquely identify a particular record in the table. (When describing an entity this is called an entity identifier)
How do you link database tables?
Tables may be linked through the use of a common attribute. This attribute must be a primary key of one of the tables, and is known as the foreign key in the second table.
What are the three possible types of relationship between entities?
one-to-one, one-to-many and many-to-many.
What is Normalisation?
Normalisation is a process used to come up with the best possible design for a relational database.
Give the four criteria that a relational database should be
No data is unnecessarily duplicated
Data is consistent throughout the database. Consistency should be an automatic consequence of not holding any duplicated data. This means that anomalies will not arise when data is inserted, amended or deleted.
The structure of each table is flexible enough to allow you to enter as many or as few items as required
The structure should enable a user to make all kinds of complex queries relating data from different tables.
Criteria of 1NF
A table in first Normal Form (1NF) if it contains no repeating attribute or groups of attributes.
Represent two entities in standard notation which have a many-to-many relationship - Product and Component
Product (PRODUCTID, ProductName, Costprice)
Component (COMPID, CompName, SupplierID, SupplierName)
Criteria of 2NF
A table is in second Normal Form (2NF) if it is in 1NF and contains no partial dependencies. 2NF is best described as partial key dependence test.
What is a partial dependency?
A partial dependency is where one or more of the attributes depends on only part of the primary key, which can only occur if the primary key is a composite key.
Criteria of 3NF
A table is in third Normal Form (3NF) if it is in second normal form and contains no ‘non-key dependencies’.
What is a non-key dependency?
A non-key dependency is one where the value of an attribute is determined by the value of another attribute which is not part of the key.
What does 3NF mean?
All attributes are dependent on the key, the whole key and nothing but the key.