1.3.2 Databases Flashcards
What is an entity?
A category of object, person, event or thing about which data is to be recorded.
What is a flat file database?
A single file where all data about a single entity is held.
What is a database?
A structured, persistent store of data, organised so that it can be easily accessed, managed and updated.
What does it mean that a database is structured?
The data is organised in a logical way to make processing simple.
What does it mean that a database is persistent?
The data remains for as long as is required.
Give some benefits of using databases.
Easy and fast to:
- Access data
- Update data
- Search for data
- Present data in a usable way
What are flat file databases suitable for?
Small amounts of data
Why are flat file databases unsuitable for large amounts of data?
Because they are cumbersome to update and prone to data redundancy.
What is data redundancy?
The unnecessary duplication of data in a database.
Why is data redundancy bad?
When updates occur, all instances of a data item must be changed.
If not all instances are updated properly, this can lead to errors when processing the data.
What is the template of an entity description?
Entity(Attribute, Attribute, Attribute…
e.g. Teacher(Title, FirstName, Surname, Subject)
How do we represent a primary key in an entity description?
Underline the attribute.
What is a primary key?
A unique identifier for each record of a particular entity.
Indexed.
What sort of databases do we use to reduce data redundancy?
Relational databases.
What is a foreign key?
The primary key of one table, present in another table in order to link the two tables.
A common attribute of both tables.
What is a secondary key?
Another indexed field in a database which can be searched quickly, but is not the primary key.
e.g. Customers may not know their customerID but would know their email address so this could be a secondary key
What is a one-to-one relationship?
A single entity links to only one other entity and this entity links back to the original entity.
e.g. Student and studentID
What is a one-to-many relationship?
A single entity links to multiple different entities however each of these entities link back to the same original entity.
e.g. Mother with multiple children
What is a many-to-many relationship?
Multiple different entities link to multiple other entities and these entities link back to multiple other entities.
e.g. A student takes multiple courses and each course is taken by multiple students.
What is each entity represented by in a relational database?
A new table
Can we have many-to-many relationships in relational databases?
No
What do we do if we need to use a many to many relationship in a relational database?
Create an extra table to link the two tables.
E.g. Students m2m Classes
Students 12m Enrollment m21 Classes
What is a composite / compound primary key?
A primary key consisting of more than one attribute.
Why would a composite primary key be used?
When the record cannot be uniquely identified by a single field.
E.g. Student, Class
or in a pack of cards, suit and number
What is referential integrity?
Ensuring that if a record cannot be deleted from one table if it is required in another table.
Can prevent deletion or delete in both tables.