1.3.2 Databases Flashcards
What is a flat-file database?
A database that consists of a single file, usually based on a single entity.
Can be written by => Entity(Attribute1, Attribute2, Attribute3)
What is a relational database?
A set of tables whose records are linked by certain fields.
What is a primary key? How is it shown in a table?
A field which has a unique value for every record.
They are underlined.
What is a secondary key?
A non-unique but specific identifier which allows data to be searched easier.
What is a foreign key?
A field which links to a primary key in a different table. It is the primary key in one table, and the foreign key in another.
What is normalisation in databases?
The process of coming up with the best possible layout for a relational database.
It tries to achieve:
- No redundancy
- Consistent data throughout linked tables
- Complex queries can be carried out
- Records can be added and removed without issues
What is 1NF?
Contains no repeating attributes (atomic) and has a primary key.
What is 2NF?
Already in 1NF and contains no partial dependencies (every field depends on the primary key).
What is 3NF?
Already in 2NF and contains no non-key dependencies.
What is referential integrity?
Changes on a database are kept consistent to ensure data isn’t used if it’s required elsewhere in a linked database.
E.g. If a record is removed, all references to it are removed.
E.g. A foreign key must have a corresponding primary key in a different table.
What does ACID stand for and what does each term mean?
Atomicity => A transaction must fully complete, not just partially.
Consistency => All transactions must follow the rules of the programming language (maintain referential integrity).
Isolation => Simultaneous execution of transactions must give the same result as if they were executed one after the other.
Durability => Once a transaction has been committed, it’ll remain so, even in the event of a powercut.
What is record locking?
Preventing simultaneous access to records in a database.
What is deadlock?
When two records are locked due to them being processed but the records depend on each other for the transaction.
What is redundancy?
Having multiple copies of the same data in physically different locations.