# Computing - Databases

> Source: https://ollybritton.com/notes/a-level/computing/topics/databases/ · Updated: 2024-08-25 · Tags: computing, fundementals-of-databases

##### What is a relational database??
A method of creating a database using tables of related data.

##### Records in a relational database are indexed by??
A primary key.

##### What is an example of tables for a car rental business??
* `Customers`
* `Rentals`
* `Vehicles`

##### What is an example of the attributes for a customer in a car rental business??
* Name
* Address
* Phone
* Email

##### What's another word for tables in a relational databse??
Relations

##### What does one row in a table represent in a relational database??
A record.

##### What does one column in a table represent in a relational database??
A column.

##### What is a flat file database??
Where all the data is stored in one table.

##### In terms of customers and rentals, what is a many-to-many relationship??
Customers can rent many different cars and cars can be rented by many different customers.

##### What is a composite key??
A key derived from a combination of other primary keys.

##### What is a key from another table called??
A foreign key.

##### What is a foreign key??
A key from another table.

##### What is the focus of a database??
The elimination of redundant data.

##### What is the benefit of creating relationships in a database??
Changes made to one part of the database are reflected across the database as a whole.

##### ![PHOTO ONE TO ONE](paste-db97fe5de0663716c71c9a5bb7da56e0dfa284e1.jpg) What does this mean in databases??
One to one.

##### ![PHOTO ONE TO MANY](paste-d4025a26d576743c2833abc63e5935b5dc6406bd.jpg) What does this mean in databases??
One to many.

##### ![PHOTO MANY TO MANY](paste-5490c5937ef07a14e0489d34ebc50259a5151938.jpg) What does this mean in databases??
Many to many.

##### What is the symbol for one to one in databases??
![PHOTO ONE TO ONE](paste-db97fe5de0663716c71c9a5bb7da56e0dfa284e1.jpg)

##### What is the symbol for one to many in databases??
![PHOTO ONE TO MANY](paste-d4025a26d576743c2833abc63e5935b5dc6406bd.jpg)

##### What is the symbol for many to many in databases??
![PHOTO MANY TO MANY](paste-5490c5937ef07a14e0489d34ebc50259a5151938.jpg)

##### Each table holds information about what in a database??
An entity.

##### Wjat is normalisation??
A process used to come up with the best possible design for a database.

##### What are the three types of normalisation??
* 1st Normal Form
* 2nd Normal Form
* 3rd Normal Form

##### What is the benefit of normalisation??
Data is not duplicated over the database.

##### What does $2NF$ mean in databases??
2nd Normal Form.

##### What is first normal form??
* No repeating attributes
* Attributes are atomic

##### Why is a `Name` column consiting of "John Doe" not atomic??
Because "John Doe" can be broken down into a first name and last name.

##### What does it mean for data to be atomic??
It cannot be split up any more than it already has.

##### ![PHOTO DATABASE NOT FIRST NORMAL FORM](paste-57a86198bef403659e288bff871ff3d6037f5502.jpg) This database is not in first normal form. Why??
Because the table contains repeated attributes.

##### ![PHOTO DATABASE NOT FIRST NORMAL FORM](paste-57a86198bef403659e288bff871ff3d6037f5502.jpg) Is this database atomic??
Yes.

##### What is second normal form??
* In first normal form
* No partial dependencies

##### When can partial dependencies occur in a table??
When the primary key is a composite key.

##### ![PHOTO TABLE ENROLLMENT](paste-433f3cfef28e4a40de3756c73c0562045ec10ac7.jpg) Why is this table in second-normal form??
There are no attributes that are dependent on only `Members` or `Classes`.

##### ![PHOTO TABLE ENROLLMENT](paste-433f3cfef28e4a40de3756c73c0562045ec10ac7.jpg) If there was a column for class name, why wouldn't the table be in second normal form??
Because class names are only relevant to the `Classes` and not `Members`. Therefore it's a partial dependency.

##### What is third normal form??
* In second normal form
* No non-key dependencies

##### What's the slogan for third normal form??
> All attributes are dependent on the key, the whole key and nothing but the key.

##### What three things could you improve about a centralised database system??
* Server hardware
* Network
* The database software

##### What four techniques can you use to deal with concurrent access to a database??
1. Record locking
2. Table locks with serialisation
3. Timestamp ordering
4. Commitment ordering

##### What is record locking??
Using a lock to prevent concurrent access to a specific part of the database.

##### What are table locks with serialisation??
Where locks are used to make sure transactions occur in the order they happened.

##### What is timestamp ordering??
Commands are executed based on the timestamp for when the data was last written or read.

##### What is commitment ordering??
In general, transactions occur in the order they are recieved but transactions that cause a deadlock with be delayed.

---
Olly Britton — https://ollybritton.com. Machine-readable index: https://ollybritton.com/llms.txt
