10 - Fundamentals of Databases Flashcards

(34 cards)

1
Q

What does it mean for relations to be in Third Normal Form.

Why is it important that the relations in a relational database are in Third Normal Form?

IGNORE (original card)

A

3NF means every non-key attribute is dependent on the key, the whole key and nothing but the key. There are also no repeating groups.

This is important to eliminate update anomalies, eliminate insertion anomalies, eliminate deletion anomalies, eliminate data inconsistency and minimise data duplication.

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

State the properties that the relations in a fully normalised database must have.
IGNORE (original card)

A
  • There are no repeating groups of attributes.
  • All non-key attributes depend on the whole key.
  • All non-key attributes depend on nothing but the key.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe a problem when a table is not normalised.
IGNORE (original card)

A

It is difficult to query as it contains repeating groups of attributes.

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

What is the name given to a key that is made up of multiple attributes?
IGNORE (original card)

A

Composite key

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

Why is it important for a database to be in third normal form?
IGNORE (original card)

A
  • Eliminate update anomalies
  • Eliminate insertion anomalies
  • Eliminate deletion anomalies
  • Eliminate data inconsistency
  • Eliminate data redundancy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a data model?

A

A data model is an abstract model of which things to store and what information about them should be recorded. It is created from data requirements when designing a database.

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

What is an entity in database design?

A

An entity is a thing about which data is to be stored, for example: a customer. Databases are formed of tables which are used to store multiple entities. Each entity usually has its own row in a table.

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

What are attributes in database design?

A

Attributes are characteristics or other information about entities, for example: the customer’s name or address. Fields of a table row hold the entity’s attributes.

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

What is an entity identifier and why is it important?

A

An entity identifier is an attribute given to each entity which is unique within that table. It’s important to ensure that each entity has a unique identifier when creating a database. Some database tables have multiple attributes which are combined to form the table’s entity identifier.

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

How do you write an entity description?

A

An entity description shows how information about an entity is stored in a database. Format: EntityName (Attribute1, Attribute2, Attribute3)

Example: Customer (CustomerID, CustomerName, CustomerAddress, CustomerEmail)

The entity identifier is underlined in the description.

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

What are the three possible degrees of relationship between tables in a relational database?

A

The three possible degrees of relationship between tables are:

  1. One-to-one: Each car has one owner, and each owner has one car
  2. One-to-many: Each car has many passengers. Each passenger sits in one car
  3. Many-to-many: Each driver can drive many different cars. Each car is driven by many different drivers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are Entity Relationship (ER) diagrams?

A

Entity relationship diagrams (or ER diagrams) are used to graphically represent the relationships between tables in a database. Tables are shown as rectangles and are joined by lines which can represent different types of relationship (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 a primary key?

A

A primary key is an attribute that provides a unique identifier for every entity in a database table. When tables are linked by a shared attribute, the attribute must be a primary key in one table.

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

What is a foreign key?

A

A foreign key is an attribute in a table which is the primary key in another, related, table. Foreign keys are used to link tables together through shared attributes.

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

What is a composite primary key?

A

A composite primary key is formed when it is not possible to create a primary key from just one attribute. Multiple attributes are combined together to form the composite primary key, ensuring uniqueness across the table.

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

How do you handle many-to-many relationships in relational databases?

A

When linking many-to-many relationships, a new table called a link table has to be created. This link table contains foreign keys from both of the related tables, allowing the many-to-many relationship to be properly represented.

17
Q

Why are databases normalised?

A

Databases are normalised so that they can be efficient without any compromise to the integrity of their data. Benefits include:

  • Faster searching and sorting thanks to smaller tables
  • Easier to maintain than unnormalised databases
  • Duplication of data is minimised
  • Data consistency is improved
  • Reduces update, insertion and deletion anomalies
18
Q

What is First Normal Form (1NF)?

A

When a database conforms to first normal form, it contains no repeating attributes. The database’s data can be referred to as atomic (meaning that no single column contains more than one value).

Example: If a staff member teaches multiple subjects, each subject must be in a separate row, not combined in one cell.

19
Q

What is Second Normal Form (2NF)?

A

In order to meet second normal form, a database must:

  1. Satisfy First Normal Form
  2. Remove partial key dependencies

A partial key dependency occurs in databases with composite primary keys when a non-key attribute doesn’t depend on the whole of the composite key. These dependencies must be moved to separate tables.

20
Q

What is Third Normal Form (3NF)?

A

In order to meet third normal form, a database must:

  1. Conform to Second Normal Form
  2. Have no non-key dependencies

A database that meets third normal form can be described as: “All non-key attributes depend on the key, the whole key and nothing but the key”

21
Q

What is SQL and what type of language is it?

A

SQL (Structured Query Language) is a language used with databases. SQL is easy to learn and use, partly because it is a declarative language, meaning that the programmer describes the result that’s required rather than describing the process which should be followed.

The four main SQL commands are: SELECT, UPDATE, INSERT and DELETE.

22
Q

What is the syntax for the SELECT command in SQL?

A

The SELECT command is used for retrieving data from a database table:

SELECT <attribute> FROM <table> WHERE <condition> ORDER BY <ASC/DESC></condition></attribute>

Note: The ORDER BY clause is optional.

Example:
SELECT FlightNo FROM Flights WHERE Destination = ‘Berlin’

23
Q

What is the syntax for the UPDATE command in SQL?

A

The UPDATE command is used for modifying the attributes of an existing entity:

UPDATE <table> SET <attribute> = <value> WHERE <attribute> = <value></value></attribute></value></attribute>

Example:
UPDATE Students SET Email = ‘beth24@yahoo.co.uk’ WHERE StudentNo = 55887

UPDATE commands usually use the table’s primary key to identify which entities to update but can use more general conditions.

24
Q

What is the syntax for the DELETE command in SQL?

A

The DELETE command is used for removing entities from a database:

DELETE FROM <table> WHERE <condition></condition>

Example:
DELETE FROM Cars WHERE Sold = TRUE

This will remove all records from the Cars table where the Sold field is TRUE.

25
What is the syntax for the INSERT command in SQL?
The INSERT command is used to add new records to an existing table: Full syntax: INSERT INTO (, , …) VALUES (, , …) Simplified (when using all columns in correct order): INSERT INTO
VALUES (, , …) Example: INSERT INTO Cars VALUES ("KA", "Ford", 3999, 2010, FALSE)
26
What are wildcards in SQL and how are they used?
Wildcards can be used in SQL commands to specify any possible value. In SQL, wildcards are usually notated with an asterisk (*). Example: SELECT * FROM Cars WHERE Price > 4000 This returns all attributes for cars with price greater than 4000. Special case: DELETE FROM Cars and DELETE * FROM Cars both delete all entries in the table.
27
How do you create a table using SQL?
SQL can be used to make new database tables with the CREATE command. This specifies the table name, attributes, data types, and keys: CREATE TABLE Artworks (Title VARCHAR(225), Artist VARCHAR(255), Date YEAR, PRIMARY KEY (Title, Artist)) This creates a table called Artworks with a composite primary key composed of Title and Artist attributes. New records can then be added using INSERT.
28
What is a client server database system?
A client server database system provides simultaneous access to a database for multiple clients. For example, social media websites store information on databases that are continuously being accessed and modified by different users simultaneously.
29
What is concurrent access and when does it become a problem?
Concurrent access occurs when different users attempt to access the same field at the same time. Issues rarely arise when two users are requesting access to different, unrelated fields in a database. However, concurrent access can result in database updates being lost if two users edit a record at the same time.
30
What are the four methods to manage concurrent access?
The four methods to manage concurrent access are: 1. Record locks 2. Serialisation 3. Timestamp ordering 4. Commitment ordering Each method provides a different approach to controlling how multiple users can access the same database records simultaneously.
31
How do record locks work?
When a record is accessed by one user, it is immediately locked to other users until the first user has finished using it. Other users are blocked from accessing or modifying the content of a field until it has been unlocked.
32
How does serialisation work in database management?
Rather than locking a field, requests from other users are placed in a queue. Once the first user has finished using the field, the next command in the queue is executed and so on. This ensures orderly processing of database requests.
33
How does timestamp ordering work?
When multiple commands are sent to the same field in a database, each is assigned a timestamp which marks the point in time at which the command was initiated. Commands are carried out on the field in the order of their timestamps.
34
How does commitment ordering work?
When a database uses commitment ordering, an algorithm is used to work out an optimum order in which to execute commands for the same field. This algorithm will take into account the impact of commands on other parts of the database and attempt to minimise issues from occurring with the database.