Relational Database Concepts Flashcards

1
Q

What is a table made up of?

A

Records

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

What are records made up of?

A

Fields

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

What are fields made up of?

A

Characters

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

Describe a table in a database.

A

Tables contain data such as students, orders, events, customers, suppliers, etc. A table is a data structure made up of rows and columns that contains data about the items.

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

What requirements must be met for the data structure to be called a table?

A

The table must have a unique name. Each field/column must have a unique name. Each record/row must be unique. Each data item within a field must contain only a single data item. The order of the records and fields does not matter.

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

Describe a record in a database.

A

A record is a single row within a table. It is a collection of data about a single item/event. A record might be about a customer, an order or an item, etc.

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

In a table, each record must be ______.

A

Unique

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

Describe a field in a database.

A

A field is an individual item within a record. Each field within a record should have a unique name. A field should only contain a single data item. Fields have individual data types and can have their own validation.

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

What is a primary key?

A

This is a field, in the table, that allows each record to be uniquely identified. Every value of the primary key must be unique.

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

What are the two types of primary key?

A

Simple or compound/composite.

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

What is a simple primary key?

A

One which is made up of a single field only, like ID.

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

What is a compound primary key?

A

One which combines more than one field to make a unique value.

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

An example of a compound primary key:

A

If we had a table showing a student, a date/time and if they are present - a student can only be in one place at a time. Therefore, combining the student name, data and period gives a unique value. These three fields could be combined to make a composite primary key.

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

What is a secondary key?

A

A secondary key is a field that is identified as being suitable for indexing the data. It is used to sort the data in a different order to the primary key. A table can have many secondary keys (every field could be a secondary key).

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

What is a foreign key?

A

A foreign key is used to link tables together. A foreign key is a field in one table that is linked to a primary key in another table.

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

What must be the same between a foreign key and a primary key in two tables being linked together?

A

The data types.

17
Q

What is an entity?

A

Put simply, a thing.

18
Q

Some observations on entities:

A

The world is made up of entities. Entities can be linked to each other by means of a relationship.

19
Q

What are the three types of relationship?

A

One to one, one to many, many to many.

20
Q

Describe a one to one relationship.

A

A school can only have one head teacher and a head teacher can only be so at one school. We discount history, so ignore the fact that the school will have had many head teachers. They currently have one. One to one’s are an unlikely relationship.

21
Q

Some examples of one to one relationships:

A

Husband to wife. Car to tax disc. Person to National Insurance Number.

22
Q

Describe a one to many relationship.

A

The most common type of relationship between entities. A library member could have several fines at the same time for different books, however each fine is owed by the same member. A mother can have several children.

23
Q

Some examples of one to many relationships:

A

Library member to fine. Mother to children. Company to employees.

24
Q

Describe a many to many relationship.

A

Many instances of an entity can be associated with many instances of another entity.

25
Q

What do many to many relationships do when normalised?

A

They break the rules of normalisation. There should be no many to many relationships in a normalised database.

26
Q

What is a link entity in a many to many relationship?

A

This is an entity that sits between the two current entities and has a one to many relationship with each. One actor is a part of many people in the cast. Many people in the cast are a part of one film.

27
Q

Some examples of many to many relationships:

A

Course to registration to student. Customer to order to product. Actor to cast to film.

28
Q

NOTE:

A

When resolving many to many relationships, the foreign key is on the many side and the primary key is on the one side.

29
Q

If ‘Customer’ was an entity, what would the attributes be?

A

Forename, Surname, Company name, Address line, etc.

30
Q

NOTE FOR DATABASES:

A

Read pages 112 - 116 in the book for a good example.