3.2 Databases Flashcards

1
Q

What are 2 types of databases?

A

flat file database
relational database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a flat file database?

A

A single file that is typically based around a single entity and its attributes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a relational database?

A

A database where a different file/table is created for each entity. The tables are linked together via attributes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why use a relational database instead of a flat file?

A

If there is a 1 to many relationship between 2 entities, multiple records will be needed for the same entity to be linked to multiple other entities. This results in redundant data/wasted space as the records will contain repeated information.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an entity?

A

An item of interest about which information is stored.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are attributes?

A

Characteristics of the entity about which data is collected.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the 3 keys?

A

primary key
secondary key
foreign key

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a primary key?

A

The field/attribute that acts as a unique identifier for each record in the table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a field and what is a record?

A

A field is a database column and a record is a database row. i.e. personID

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a foreign key?

A

The attribute that links 2 database tables together. This acts as the primary key of one table and the foreign key of another.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a secondary key?

A

An attribute that is used for indexing in order to search for records quickly or put records in order i.e. name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are 3 types of table entity relationships?

A

one-to-one
one-to-many
many-to-many

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the one-to-one relationship?

A

Each entity can only be associated with one other entity i.e. husband and wife

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the one-to-many relationship?

A

One entity can be associated with many other entities i.e. mother and children

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the many-to-many relationship?

A

One entity can be associated with many other entities and the same the other way around i.e. students and courses

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How are these shown in diagrams?

A

direct line attached to a table is one

three lines attached to the table is many

17
Q

What is normalisation?

A

The process of creating the best possible layout for a relational database.

18
Q

What are the aims of normalisation?

A
  • remove unnecessary duplicates (minimise data redundancy)
  • consistent data throughout linked tables (maximise data consistency)
  • records can be added/removed without causing issues
19
Q

What are 3 types of normalisation?

A

1st 2nd and 3rd normal form

20
Q

What are the requirements for 1st normal form?

A

data is atomic
no repeating fields
contains a primary key

21
Q

What are the requirements for 2nd normal form?

A

1nf
every field is dependent on the primary key

22
Q

What are the requirements for 3rd normal form?

A

2nf
all attributes depend on the primary key, the whole primary key and nothing but the primary key

i.e. no transitive relationships
(non key fields can’t depend on other non key fields)

23
Q

What is indexing?

A

Storing the position of each record in the order of a specific attribute. This is automatically the primary key but typically a secondary key will be indexed to make data easier and quicker to search for.

24
Q

What does SQL stand for?

A

structured query language

25
Q

What is referential integrity and why is it important?

A

Making sure every foreign key links to an existing valid primary key in another table. This ensures data consistency throughout a relational database.

26
Q

How can referential integrity be broken?

A

If the primary key in a table is updated or deleted but the foreign key referencing it hasn’t been changed.

27
Q

What is a transaction?

A

A single operation executed on data.

28
Q

What is ACID and what does it stand for?

A

The rules for transaction processing in databases.

atomicity
consistency
isolation
durability

29
Q

What is atomicity?

A

A transaction must be processed in its entirety or not at all.

30
Q

What is consistency?

A

A transaction must maintain the referential integrity rules between linked tables.

31
Q

What is isolation and how is it acheived?

A

Simultaneous execution of transactions should lead to the same result as if they were processed at separate times. This can be achieved through record locking.

32
Q

What is durability and how is it achieved.

A

Once a transaction has been executed, it will remain so no matter what happens e.g. power cut. This is achieved by storing all completed transactions in secondary storage as it’s non-volatile.

33
Q

What is record locking?

A

Preventing simultaneous access to records in a database to prevent inconsistencies or loss of updates.

34
Q

What is a problem that can be caused by record locking?

A

deadlock

user 1 accesses record 1
user 2 accesses record 2

user 1 tries to access record 2 at the same time as user 2 tries to access record 1

both are waiting for the other record to be free resulting in no progress

35
Q

What is data redundancy?

A

When the same piece of data exists multiple times in different locations.