This Approach Is Not Very Popular in Practice Because It Suffers From The
This Approach Is Not Very Popular in Practice Because It Suffers From The
Chapter 2: SQL: SQL data definition and data types, specifying constraints in SQL, retrieval queries
in SQL, INSERT, DELETE, and UPDATE statements in SQL, Additional features of SQL.
CHAPTER 1
Example of Violating
Guideline 1:
EMP_DEPT Dnumber Dname Dmgr ssn
Ename Ssn Bdate Address
2. Reducing the redundant information in tuples.
" One goal of schema design is to minimize the storage space used by the base relations
(and hence the corresponding files).
" Grouping attributes into relation schemas has a significant effect on storage space.
Storing natural joins of base relations leads to an additional problem referred to as
update anomalies.
These can be classified into insertion anomalies, deletion anomalies, and modification
anomalies
> Insertion Anomalies. Insertion anomalies can be differentiated into two types,
illustrated by the following examples based on the EMP_DEPT relation:
To insert a new employee tuple into EMP_DEPT, we must include either the attribute
values for the department that the employee works for, or NULLs (if the employee
does not work for a department as yet). For example, to insert a new tuple for an
employee who works in department number 5, we must enter all the attribute values
of department 5 correctly so that they are consistent with the corresponding values
for department 5 in other tuples in EMP_DEPT.
> Deletion Anomalies. The problem of deletion anomalies is related to the second
insertion anomaly situation just discussed. If we delete from EMP_DEPT an employee
tuple that happens to represent the last employee working for a particular department,
the information concerning that department is lost inadvertently from the database.
> Modification Anomalies. In EMP_DEPT, if we change the value of one of the attributes
of a particular department-say, the manager of department 5-we must update the
tuples of all employees who work in that department; otherwise, the database will
become inconsistent. f we fail to update some tuples, the same department will be
shown to have two different values for manager in different employee tuples, which
would be wrong
" Guideline 2. Design the base relation schemas so that no insertion, deletion, or
modification anomalies are present in the relations. Ifany anomalies are present, note
RBT: L1, L2, L3
CHAPTER 1
The data type describing the types of values that can appear in each column is
represented by a DOMAIN of possible values.
A domain D is a set of atomic values.
" By atomic we mean that each value in the domain is indivisible as far as the
formal relational model is concerned.
Acommon method of specifying a domain is to specify a data type from which
the data values forming the domain are drawn.
It is also useful to specify a name for the domain, to help in interpreting its
values.
Adata type or format is also specified for each domain.
Example 1: the data type for the domain Usa_phone_numbers can be declared
as a character string of the form (ddd)ddd-dddd, where each d is a numeric
(decimal) digit and the first three digits form avalid telephone area code.
" Example 2: The data type for Employee_ages is an integer number between 15
and 80.
. Arelation schema R, denoted by R(A1, A2, .., A), is made up of arelation name
Rand a list of attributes, A1, Az,.. An. Each attribute Ai is the name ofa role
played by some domain D in the relation schema R. D is called the domain of A
and is denoted by dom(A).
A relation schema is used to describe a relation; R is called the name of this
relation.
The degree (or arity) of a relation is the number of attributes n of its relation
schema.
" A relation of degree seven, which stores information about university students,
would contain seven attributes describing each student as follows:
STUDENT(Name, Ssn, Home_phone, Address, Office_phone, Age, Gpa)
" A relation (or relation state)4 r of the relation schema R(A1, Az, .. , An), also
denoted by r(R), is a set of n-tuples r= (ti, t2, .., tm).
" Each n-tuple tis an ordered list of n values t=<VL V2, ..., Vn>, where
each value vi,
1<=i<=n, is an element of dom (A) or is aspecial NULL value.
The i th value in tuple t, which corresponds to the attribute A,, is referred to as
t[A] or t. A(or t[] if we use the positional notation).
The terms relation intension for the schema R and relation
extension for a
relation state r(R) are also commonly used.
The earlier definition of a relation can be restated more formally using set theory
concepts as follows.
Arelation (or relation state) r(R) is a mathematical relation of degree n on the
domains dom(A1), dom(A2), ...,dom(An), which is a subset of the Cartesian
product (denoted by x) of the domains that define R:
r(R)e (dom(A1) x dom(Az) x... x (dom(An)
Attnbutes
Relation Name
STUDENT
Name Ssr Home phone Address Ofice phone Age Gpa
Benjamin Bayer305-61-2435 (817)373-1616 2918 Bluebonnet Lane NULL 19321
Chung cha Kim 381-62-1245 (817)3754409 125 Kirby Road NULL 18 289
Rohan Panchal480 22 1100 (817)376 9821 265 Lark Lane (817)749 6492 28 R93
CHARACTERISTICS OF RELATIONS
Page 3 of 40