CH5 The Relational Data Model and Relational Database Constraints Flashcards
Define relation schema
- list of attri- butes that describe the structure of a relation
- A relation schema2 R, denoted by R(A1, A2, … , An), is made up of a relation name R and a list of attributes, A1, A2, … , An. Each attribute Ai is the name of a role played by some domain D in the relation schema R.
- Ex: STUDENT(Name, Ssn, Home_phone, Address, Office_phone, Age, Gpa)
Define relation state,
- set of tuples that conforms to the schema
- A relation (or relation state)4 r of the relation schema R(A1, A2, … , An), also denoted by r(R), is a set of n-tuples r = {t1, t2, … , tm}. Each n-tuple t is an ordered list of n valuest=,whereeachvaluevi,1≤i≤n,is
5.6. Discuss the characteristics of relations that make them different from ordi- nary tables and files.
- the first is that a relation is not sensitive to the ordering of tuples.
- The second involves the ordering of attributes in a relation schema and the corresponding ordering of val- ues within a tuple. n abstract level, since there really is no reason to prefer having one attribute value appear before another in a tuple.
5.7. Discuss the various reasons that lead to the occurrence of NULL values in relations.
- val- ues in tuples and introduced NULL values to represent missing or unknown infor- mation.
- value unknown, value exists but is not available, or attribute does not apply
- NULL values should be avoided as much as possible.
5.8. Discuss the entity integrity and referential integrity constraints. Why is each considered important?
- entity integrity constraint, which prohibits primary key attri- butes from being NULL. Important because it let’s that every entity is identified
- the referential integrity constraint Informally, the referen- tial integrity constraint states that a tuple in one relation that refers to another rela- tion must refer to an existing tuple in that relation or be null
Define tuple
a row is called a tuple
- Each value in a tuple is an atomic value; t
Define attribute
, a column header is called an attribute,
Define domain
- A domain D is a set of atomic values.
- A domain is thus given a name, data type, format and additional info (measurement unit)
- logical definitions of domains. Ex: Usa_phone_numbers. The set of ten-digit phone numbers valid in the United States.
- Data type describing the types of values that can appear in each column is represented by a domain of possible values
Why are tuples in a relation not ordered?
- A relation is defined as a set of tuples. Math- ematically, elements of a set have no order among them
- Tuple ordering is not part of a relation definition because a relation attempts to rep- resent facts at a logical or abstract level.
5.3. Why are duplicate tuples not allowed in a relation?
- In the formal relational model, a relation is defined as a set of tuples. By definition, all elements of a set are distinct; hence, all tuples in a relation must also be distinct.
5.4. What is the difference between a key and a superkey?
- Difference is that the superkey may be a minimal superkey and the key must be a minimal superkey
- Example: l). Consider the STUDENT relation of Figure 5.1. The attribute set {Ssn} is a key of STUDENT because no two student tuples can have the same value for Ssn.8 Any set of attributes that includes Ssn—for example, {Ssn, Name, Age}—is a superkey. However, the superkey {Ssn, Name, Age} is not a key of STUDENT because removing Name or Age or both from the set still leaves us with a superkey.
Define superkey
subsets of attributes of a relation schema R with the property that no two tuples in any relation state r of R should have the same combination of values for these attributes.
Define key
- A key k of a relation schema R is a superkey of R with the additional property that removing any attri- bute A from K leaves a set of attributes K′ that is not a superkey of R any more.
- Uniqueness property and minimal superkey
5.5. Why do we designate one of the candidate keys of a relation to be the pri- mary key?
- to identify tuples in the relation.
- s somewhat arbitrary; however, it is usually better to choose a primary key with a single attribute or a small number of attributes.
Define relational database schema
- A relational database schema S is a set of relation schemas S = {R1, R2, … , Rm} and a set of integrity constraints IC.
- Example: a diagram of the tables, attributes and relations