3. Relational Model - 3marks Flashcards

1
Q

What is the relational model (background and four basic concepts)?

A
Background: 
•	Introduced by E.F. Codd in 1970. 
•	Many DBMS products based on this model (but few completely implement it). 
•	Based on sound theoretical foundation with a simple and uniform data structure: the Relation 
•	Based on mathematical set theory. 
Four basic concepts: 
•	Relations 
•	Domains 
•	Attributes 
•	Tuples
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

A relation is (informally):

A
  • a set of records

* similar to a table with columns and rows

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

What is the main construct for representing data in the relational model?

A

A relation

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

A Schema is…

A
  • the meta-data, or data describing data

* specified during database design, and is not expected to change frequently

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

An Instance is

A
  • the data in the database at a particular time

* created during data updates and change frequently

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

A domain is characterised by….

A
  • a set of atomic values (ie: indivisible) (eg: the domain ‘Name’ has the set { Albert, Anna, …. Zoe }
  • it’s specified data type or format
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Domain data types of formats could include…

A
  • integers
  • real numbers
  • fixed or variable length character strings
  • date
  • time stamp
  • currency
  • sub-range from a data type, e.g. 1 ≤ Grade ≤ 7
  • enumerated data type, e.g. {‘Male’, ‘Female’}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

An attribute is linked to a domain in that it is…

A

• the name of a role played by some domain in the relation named

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

Does the same attribute name imply the same domain?

A

• No. Two attributes could be called ‘code’ from different domains: eg: Subject.CODE and Lecturer.CODE.

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

Does a different attribute name imply a different domain?

A

• No. a different attribute name does not necessarily imply different domain (Domains for EID and SID can be the same, but the attribute names must differ.

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

A tuple is…

A
  • n ordered list of n values
  • where each value vi (1  i  n) is an element of the corresponding domain of attribute Ai or a special value called “null”
  • Usually shown as a row in DB.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Relations are sets of tuples. Do they have an order in a database?

A
  • Not mathematically and practically - order is irrelevant.

* However, the physical storage has some partial ordering.

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

Relational database design is (one sentence) the process of:

A

• capturing the semantics of an application, and translating it into a relational database schema

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

What are some consequences of poor relational database design?

A
  • Poor design can lead to redundant information in tuples and update anomalies.
  • Can also result in inability to represent information and consequently, loss of information.
  • Conceptual modelling, and other formal techniques, can assist a designer in obtaining good design characteristics.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Where are integrity constraints defined?

A

On the database schema.

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

What are the four integrity constraints enforced by a DBMS?

A
  1. Key (uniqueness) Constraint
  2. Entity Integrity
  3. Referential Integrity
  4. Domain Constraint
    Acronym to remember: KERD
17
Q

Key (aka uniqueness) Constraint implies:

A

• No two tuples can have the same value for their primary key attributes

18
Q

Entity Integrity constraints are:

A
  • Primary key values CAN NOT be null.

* In a composite key, NO PART of the KEY can be NULL (eg: store ID and product ID)

19
Q

Referential Integrity constraints are:

A
  • Foreign key must reference a value which exists
  • Tables need to be connected correctly through primary keys and foreign keys.
  • No database will have more than one table
20
Q

Domain Constraints are:

A

Every attribute in the relational model comes from some domain.
• No value from one domain can be put into another (eg: text in numerical).
• Can not put multiple values (must be atomic)

21
Q

A Primary Key is:

A

The attribute or combination of attributes that uniquely identifies a row or record in a relation.

22
Q

A superkey is:

A

a combination of attributes that can be uniquely used to identify a database record.
NB: A table might have many super keys.

23
Q

Minimal Super key (or just minimal key) is:

A

a superkey with no redundant attributes.

(EG: RegID uniquely identifies a vehicle, ManufacturerName uniquely identifies a manufacturer, to uniquely identify a car you need both it’s Make and Model.
However multiple car manufacturers can be founded in the same year, meaning YearFounded is not a superkey for manufacturer and so cannot be a minimal key. )

24
Q

A Candidate Key is:

A

The fields or combination of fields that could be used as a primary key are known as candidate keys or alternate keys.

25
Q

A Foreign Key is:

A

an attribute or combination of attributes in a relation whose value match a primary key in another relation.
• The table in which foreign key is created is called a dependent (child) table.
• The table to which foreign key is refers is known as parent table.

26
Q

Other general ‘structural’ integrity constraints could include:

A

Semantic Constraints
• “The salary of an employee should not exceed the employee’s supervisor’s
salary”
• “The maximum number of hours that an employee can work on a project is 56”
Transition Constraints
• “The salary of an employee can only increase”
These are often implemented in a constraint specification language
Eg: (SQL3) using triggers and assertions

27
Q

Why is enforcement of integrity constraints important to a DB?

A

It ensures that the database remains consistent

28
Q

If a database is changed or updated, can integrity constraints be violated?

A

No.