INTRODUCTION TO THE RELATIONAL MODEL Flashcards
What is a relation?
A table in a database that has tuples (rows) and attributes (columns)
What is a set?
A collection of related objects considered an object in it’s own right
What is an attribute?
A named column of a relation. Each attribute of a relation is a set
Describe a domain
Every attribute in a relation is defined based on a domain
This allows a database designer to define all the acceptable values that can be held by an attribute and all semantically correct relational operations
How can a domain be specified?
A common method of specifying a domain is to specify a data type from which the data values (that are elements of the attribute) are drawn
For example, the attribute
National_ID_number should store data values that are of the type integer. More specifically, only 8 integers (in Kenya).
What is the intension of a relation (relation schema) ?
The structure of a relation, together with a specification of the domains and any other restrictions on possible values is called its intension
What is the extension of a relation ?
The tuples are called the extension (or state) of a relation. This changes over time.
What is a relational database schema
a set of relation schemas, each with a distinct name
What is the degree of a relation?
The number of attributes it contains
*The degree is a property of the intension of a relation
Examples of degrees of relations
- Unary relation (one attribute)
- Binary (two attributes),
- Ternary (three attributes),
- n-ary
What is the cardinality of a relation?
The cardinality of a relation is the number of tuples it contains
- The cardinality is a property of the extension of a relation. The cardinality is therefore determined
from the particular state of the relation at
any given moment
List the properties of a relation.
- A relation must have a distinct name
- Each cell of a tuple’s relation consists of exactly one atomic (single) value
- Each attribute must have a distinct name
- The values of an attribute are all from the same domain
- The order of attributes does not matter
- The order of tuples does not matter
Define a relational key
One or more attributes are needed to uniquely identify each tuple in a relation.
Give the different types of relational keys
1.Superkey- an attribute or a set of attributes that uniquely identifies a tuple within a relation
2.Candidate key- an attribute, or set of attributes, in a relation that can uniquely identify any tuple without referring to any other data
• A candidate key is therefore a special subset of a superkey
• Each relation may have one or more candidate keys, but one candidate key is special, and it is called the primary key
3. Primary key- The candidate key that is selected to
identify tuples uniquely within the relation
• Candidate keys that are not selected to be the primary key are called alternate keys
4.Foreign key-An attribute, or set of attributes, within
one relation that matches a relational key of another relation
5.Composite key- A relational key that is made up of more than one attribute
Describe integrity constraints and give the different types with examples (actual relations)
Integrity constraints are a set of rules. It is used to maintain the quality of information based on guidelines set by the database administrator
1.Domain constraints - the definition of a valid set of values for an attribute. (Data types) Eg no strings in age attribute
2.The entity integrity constraint states that primary key value can’t be null. Draw a table with one tuple with a null value
3.Referential Integrity Constraints -specified between two tables. In the Referential integrity constraints, if a foreign key in Table 1 refers to the Primary Key of Table 2, then every value of the Foreign Key in Table 1 must be available in Table 2. Draw two tables one with more tuples than the other
4.Key constraints
Keys are the entity set that is used to identify an entity within its entity set uniquely. Draw table with two tuples with same PK
5.A CHECK integrity constraint on a column or set of columns requires that a specified condition be true or unknown for every row of the tabl
What is a base relation?
A named relation corresponding to an entity in the
conceptual schema, whose tuples are physically stored in the database
Describe entity integrity.
In a base relation, no attribute of a primary key can be null. Null represents the absence of a value
Describe referential integrity
if a foreign key (FK) exists in a relation, the FK value must match a candidate key value of some tuple
in its home relation
Describe general constraints
Additional rules specified by the users or database
administrators of a database that define or constrain some aspect of the enterprise
What is a view?
the dynamic result of one or more relational operations operating on the base relations to define another
relation without changing the original relation
What is the purpose of a view?
- Views provide confidentiality by hiding parts of a relation that are not relevant to a user
- Views permit users to access data in a way that is customized to their needs
- Views can simplify complex operations on the base relations
The relational data model emphasizes two principal integrity rules. Define the rules and state
why it is desirable to enforce each of these rules
Entity integrity- It says that no component of a primary key may be null.
Referential integrity
The referential integrity constraint is specified between two relations and is used to maintain the consistency among tuples of the two relations. The referential integrity constraint states that, a tuple in one relation that refers to another relation must refer to the existing tuple in that relation.
Integrity constraints ensure that the data insertion, updating, and other processes have to be performed in such a way that data integrity is not affected.
Thus, integrity constraint is used to guard against accidental damage to the database.