What is a database?
A large store of categorised data
What is a flat file database?
A database with only one table
What is normalisation?
The process of converting a flat file database into a relational database.
Describe how to convert to first normal form?
Split multi valued attributes into two different rows by ensuring atomic values.
E.g. if the field “subject” has values maths,science
It should be split into two different entities one with subject science and one with subject maths
Describe how to convert to second normal form?
Remove partial dependencies by splitting tables.
Describe how to convert to third normal form?
Remove transistors dependencies. (No column in a table should depend on a non key attribute in said table)
What are the three types of relationships between tables in an ERD?
1 to 1
Many to 1
Many to many
Show what a database schema would look like:
Customers (CustID, Nam, Town)
Orders (OrderID, CustID)
What are the three types of key?
Primary key
Foreign key
Composite key
How can you easily tell if there is a many relationship?
If the primary key of table 1 appears as a foreign key in table 2 then table 1 has a 1 to many relationship with table 2.
What is the lost update problem?
When two users try to update the same record simultaneously the record will be inconsistent between users after being edited.
What are the two methods implemented to combat the lost update problem?
Record locks
Transaction queueing
Describe how record locking works:
If another user is accessing a record other users are not able to access it until the user is no longer accessing it.
What is transaction queuing?
Database changes are grouped as transactions and queued.
Database software processes the transactions in FIFO order from the queue.
Write a generic SQL update statement
UPDATE table name
SET column=value, column2=value2
WHERE condition
Write a generic SQL fetch statement
SELECT column1, column2
FROM table name
WHERE condition
Write a generic SQL delete statement
DELETE FROM table name
WHERE condition e.g. column=value
Write a generic SQL write statement
INSERT INTO table name (column1,…)
VALUES (value1,…)
Write a generic parameterised SQL statement
SELECT table1.column, table2.column
FROM table1, table2
WHERE table1.sharedColumn=table2.sharedColumn AND condition