Professional Documents
Culture Documents
Yonas Y.
Outline
Yonas Y.
When a relation is thought of as a table of values, each row in the table The Relational Data
Model Concepts
represents a collection of related data values. A row represents a fact Relational Model
Concepts
that typically corresponds to a real-world entity or relationship. Relational Model
Constraints and
Relational Database
Schemas
Update Operations,
Transactions, and
Dealing with
Constraint Violations
Object and
Object-Relational
Databases
Overview of Object
Database Concepts
Extensible Markup
Language
Structured,
Semistructured, and
Unstructured Data
XML Hierarchical
(Tree) Data Model
When a relation is thought of as a table of values, each row in the table The Relational Data
Model Concepts
represents a collection of related data values. A row represents a fact Relational Model
Concepts
that typically corresponds to a real-world entity or relationship. Relational Model
Constraints and
Relational Database
In the formal relational model terminology, a row is called a tuple, a Schemas
Update Operations,
column header is called an attribute, and the table is called a relation. Transactions, and
Dealing with
The data type describing the types of values that can appear in each Constraint Violations
Object and
column is represented by a domain of possible values. Object-Relational
Databases
Overview of Object
Database Concepts
Extensible Markup
Language
Structured,
Semistructured, and
Unstructured Data
XML Hierarchical
(Tree) Data Model
When a relation is thought of as a table of values, each row in the table The Relational Data
Model Concepts
represents a collection of related data values. A row represents a fact Relational Model
Concepts
that typically corresponds to a real-world entity or relationship. Relational Model
Constraints and
Relational Database
In the formal relational model terminology, a row is called a tuple, a Schemas
Update Operations,
column header is called an attribute, and the table is called a relation. Transactions, and
Dealing with
The data type describing the types of values that can appear in each Constraint Violations
Object and
column is represented by a domain of possible values. Object-Relational
Databases
Overview of Object
Domains, Attributes, Tuples, and Relations Database Concepts
Extensible Markup
A domain D specify the name, data type and format of the data values. Language
Some examples of domains follow: Structured,
Semistructured, and
Unstructured Data
I Names: The set of character strings that represent names of XML Hierarchical
(Tree) Data Model
persons.
I Grade point averages. Possible values of computed grade point
students, would contain five attributes describing each student as Object and
Object-Relational
follows: Databases
Overview of Object
Database Concepts
STUDENT(Name, IDNo, Address, Age, Gpa)
Extensible Markup
Language
Using the data type of each attribute, the definition is sometimes Structured,
Semistructured, and
written as: Unstructured Data
XML Hierarchical
(Tree) Data Model
STUDENT(Name: string, IDNo: string, Address: string, Age: integer,
Gpa: real)
Values and NULLs in the Tuples. NULL values are used to represent Yonas Y.
the values of attributes that may be unknown or may not apply to a Outline
tuple. The Relational Data
In general, we can have several meanings for NULL values, such as Model Concepts
Relational Model
value unknown, value exists but is not available, or attribute does not Concepts
Relational Model
apply to this tuple (also known as value undefined). Constraints and
Relational Database
Schemas
Update Operations,
Transactions, and
Dealing with
Constraint Violations
Object and
Object-Relational
Databases
Overview of Object
Database Concepts
Extensible Markup
Language
Structured,
Semistructured, and
Unstructured Data
XML Hierarchical
(Tree) Data Model
Values and NULLs in the Tuples. NULL values are used to represent Yonas Y.
the values of attributes that may be unknown or may not apply to a Outline
tuple. The Relational Data
In general, we can have several meanings for NULL values, such as Model Concepts
Relational Model
value unknown, value exists but is not available, or attribute does not Concepts
Relational Model
apply to this tuple (also known as value undefined). Constraints and
Relational Database
Schemas
Update Operations,
Transactions, and
Interpretation (Meaning) of a Relation. The relation schema can be Dealing with
Constraint Violations
interpreted as a declaration or a type of assertion. Object and
For example, the schema of the STUDENT relation in table 2.1 asserts Object-Relational
Databases
that, in general, a student entity has a Name, IDNo, Address, Age, and Overview of Object
Database Concepts
Gpa.
Extensible Markup
Each tuple in the relation can then be interpreted as a fact or a Language
particular instance of the assertion. Structured,
Semistructured, and
Unstructured Data
For example, the first tuple of STUDENT asserts the fact that there is XML Hierarchical
a student whose Name is Abebe, Age is 21, and so on. (Tree) Data Model
Yonas Y.
We will use the following notation in our presentation:
Outline
I A relation schema R of degree n is denoted by R(A1 , A2 , ..., An ). The Relational Data
Model Concepts
I The uppercase letters Q, R, S denote relation names. Relational Model
Concepts
I The lowercase letters q, r, s denote relation states. Relational Model
Constraints and
Relational Database
I The letters t, u, v denote tuples. Schemas
Update Operations,
I In general, the name of a relation schema such as STUDENT also Transactions, and
Dealing with
indicates the current set of tuples in that relation-the current Constraint Violations
Object and
relation state-whereas STUDENT(Name, IDNo, ...) refers only to Object-Relational
the relation schema. Databases
Overview of Object
Database Concepts
I An attribute A can be qualified with the relation name R to which
Extensible Markup
it belongs by using the dot notation R.A - for example, Language
STUDENT.Name or STUDENT.Age. Structured,
Semistructured, and
Unstructured Data
I An n-tuple t in a relation r (R) is denoted by t =< v1 , v2 , ..., vn >, XML Hierarchical
(Tree) Data Model
where vi is the value corresponding to attribute Ai . The following
notation refers to component values of tuples.
Yonas Y.
I Both t[Ai ] and t.Ai (and sometimes t[i]) refer to the value vi in t
for attribute Ai . Outline
Yonas Y.
I Domain Constraints
Domain constraints specify that within each tuple, the value of Outline
each attribute A must be an atomic value from the domain The Relational Data
Model Concepts
dom(A). Relational Model
The data types associated with domains typically include standard Concepts
Relational Model
numeric data types for integers (such as short integer, integer, and Constraints and
Relational Database
Schemas
long integer) and real numbers (float and double-precision float). Update Operations,
Characters, Booleans, fixed-length strings, and variable-length Transactions, and
Dealing with
Constraint Violations
strings are also available, as are date, time, timestamp, and money,
Object and
or other special data types. Object-Relational
Databases
Overview of Object
Database Concepts
Extensible Markup
Language
Structured,
Semistructured, and
Unstructured Data
XML Hierarchical
(Tree) Data Model
Yonas Y.
I Domain Constraints
Domain constraints specify that within each tuple, the value of Outline
each attribute A must be an atomic value from the domain The Relational Data
Model Concepts
dom(A). Relational Model
The data types associated with domains typically include standard Concepts
Relational Model
numeric data types for integers (such as short integer, integer, and Constraints and
Relational Database
Schemas
long integer) and real numbers (float and double-precision float). Update Operations,
Characters, Booleans, fixed-length strings, and variable-length Transactions, and
Dealing with
Constraint Violations
strings are also available, as are date, time, timestamp, and money,
Object and
or other special data types. Object-Relational
Databases
I Key Constraints and Constraints on NULL Values Overview of Object
Database Concepts
In the relational model, no two tuples can have the same
Extensible Markup
combination of values for all their attributes. Usually, there are Language
Structured,
subsets of attributes of a relation schema R with the property Semistructured, and
Unstructured Data
that no two tuples in any relation state r of R should have the XML Hierarchical
(Tree) Data Model
same combination of values for these attributes.
Suppose that we denote one such subset of attributes by SK; then
for any two distinct tuples t1 and t2 in a relation state r of R, we
have the constraint that:
t1 [SK ] 6= t2 [SK ]
AAiT - School of Electrical and Computer Engineering 22
Any such set of attributes SK is called a superkey of the relation
schema R. Every relation has at least one default superkey-the set of all Chapter 2
its attributes. Yonas Y.
Outline
property that removing any attribute A from K leaves a set of attributes The Relational Data
Model Concepts
K that is not a superkey of R any more. Hence, a key satisfies two Relational Model
Concepts
properties: Relational Model
Constraints and
1. Two distinct tuples in any state of the relation cannot have Relational Database
Schemas
identical values for (all) the attributes in the key. This first Update Operations,
Transactions, and
property also applies to a superkey. Dealing with
Constraint Violations
2. It is a minimal superkey -that is, a superkey from which we cannot Object and
Object-Relational
remove any attributes and still have the uniqueness constraint in Databases
Overview of Object
condition 1 hold. Database Concepts
Extensible Markup
Hence, a key is also a superkey but not vice versa. Language
Structured,
Semistructured, and
Unstructured Data
XML Hierarchical
(Tree) Data Model
property that removing any attribute A from K leaves a set of attributes The Relational Data
Model Concepts
K that is not a superkey of R any more. Hence, a key satisfies two Relational Model
Concepts
properties: Relational Model
Constraints and
1. Two distinct tuples in any state of the relation cannot have Relational Database
Schemas
identical values for (all) the attributes in the key. This first Update Operations,
Transactions, and
property also applies to a superkey. Dealing with
Constraint Violations
2. It is a minimal superkey -that is, a superkey from which we cannot Object and
Object-Relational
remove any attributes and still have the uniqueness constraint in Databases
Overview of Object
condition 1 hold. Database Concepts
Extensible Markup
Hence, a key is also a superkey but not vice versa. Language
Structured,
Semistructured, and
Considering the STUDENT relation in table 2.1, the attribute set Unstructured Data
{IDNo} is a key of STUDENT because no two student tuples can have XML Hierarchical
(Tree) Data Model
the same value for phone number. Any set of attributes that includes
{IDNo} - for example, {IDNo, Name, Age} - is a superkey.
A key with multiple attributes must require all its attributes together to
have the uniqueness property.
AAiT - School of Electrical and Computer Engineering 25
In general, a relation schema may have more than one key. In this case,
each of the keys is called a candidate key. Chapter 2
Yonas Y.
For example,
Outline
The CAR relation in table 2.2 has two candidate keys: License number
The Relational Data
and Engine serial no. Model Concepts
It is common to designate one of the candidate keys as the primary key Relational Model
Concepts
of the relation, which is underlined. This is the candidate key whose Relational Model
Constraints and
values are used to identify tuples in the relation. The other candidate Relational Database
Schemas
keys are designated as unique keys, and are not underlined. Update Operations,
Transactions, and
Dealing with
Constraint Violations
CAR Object and
License number Engine serial no Make Model Year Object-Relational
Databases
(AA)(2)(A10253) A69352 Mercedes 190-D 99 Overview of Object
Database Concepts
(AA)(3)(79532) B43696 Toyota Yaris 02
Extensible Markup
(AA)(4)(55431) X83554 Toyota Corolla 94 Language
(SP)(4)(15230) U028365 Ford Mustang 00 Structured,
Semistructured, and
Table: 2.2 The CAR relation, with two candidate keys: License number and Unstructured Data
XML Hierarchical
Engine serial no. (Tree) Data Model
DB = r1 , r2 , ..., rm such that each ri is a state of Ri and such that the ri The Relational Data
Model Concepts
relation states satisfy the integrity constraints specified in IC. Relational Model
Concepts
Relational Model
Constraints and
Relational Database
Schemas
Update Operations,
Transactions, and
Dealing with
Constraint Violations
Object and
Object-Relational
Databases
Overview of Object
Database Concepts
Extensible Markup
Language
Structured,
Semistructured, and
Unstructured Data
XML Hierarchical
(Tree) Data Model
DB = r1 , r2 , ..., rm such that each ri is a state of Ri and such that the ri The Relational Data
Model Concepts
relation states satisfy the integrity constraints specified in IC. Relational Model
Concepts
Relational Model
Figure 2.1 shows a relational database schema that we call Constraints and
Relational Database
COMPANY = {EMPLOYEE, DEPARTMENT, DEPT LOCATIONS, Schemas
Update Operations,
PROJECT, WORKS ON, DEPENDENT}. Transactions, and
Dealing with
Constraint Violations
EMPLOYEE Object and
Object-Relational
Name FName TinNo Bdate Sex Salary S TinNo Dno Databases
Overview of Object
Database Concepts
DEPARTMENT Extensible Markup
Language
Dname Dnumber Mgr TinNo Mgr start date Structured,
Semistructured, and
Unstructured Data
XML Hierarchical
DEPT LOCATIONS (Tree) Data Model
Dnumber Dlocation
PROJECT
Pname Pnumber Plocation Dnum
AAiT - School of Electrical and Computer Engineering 28
WORKS ON
ETinNO Pno Hours
Chapter 2
DEPENDENT Yonas Y.
DEPENDENT Yonas Y.
ProductZ 3 A.A 5
Computerization 10 DireDawa 4
Reorganization 20 A.A 1
Newbenefits 30 DireDawa 4
AAiT - School of Electrical and Computer Engineering 33
WORKS ON
ETinNO Pno Hours
123456789 1 32.5 Chapter 2
NULL. This is because the primary key value is used to identify Yonas Y.
NULL. This is because the primary key value is used to identify Yonas Y.
NULL. This is because the primary key value is used to identify Yonas Y.
Notice that a foreign key can refer to its own relation. Object and
Object-Relational
For example, Databases
Overview of Object
The attribute S TinNo in EMPLOYEE refers to the supervisor of an Database Concepts
employee; this is another employee, represented by a tuple in the Extensible Markup
Language
EMPLOYEE relation. Hence, S TinNo is a foreign key that references Structured,
Semistructured, and
the EMPLOYEE relation itself. Unstructured Data
XML Hierarchical
(Tree) Data Model
The DDL includes provisions for specifying the various types of
constraints so that the DBMS can automatically enforce them.
Yonas Y.
The operations of the relational model can be categorized into
retrievals and updates. Outline
There are three basic operations that can change the states of relations The Relational Data
Model Concepts
in the database: Insert, Delete, and Update (or Modify). Relational Model
Concepts
Relational Model
Constraints and
Relational Database
Schemas
Update Operations,
Transactions, and
Dealing with
Constraint Violations
Object and
Object-Relational
Databases
Overview of Object
Database Concepts
Extensible Markup
Language
Structured,
Semistructured, and
Unstructured Data
XML Hierarchical
(Tree) Data Model
Yonas Y.
The operations of the relational model can be categorized into
retrievals and updates. Outline
There are three basic operations that can change the states of relations The Relational Data
Model Concepts
in the database: Insert, Delete, and Update (or Modify). Relational Model
Concepts
Relational Model
The Insert Operation Constraints and
Relational Database
Schemas
The Insert operation provides a list of attribute values for a new tuple t Update Operations,
Transactions, and
Dealing with
that is to be inserted into a relation R. The main constraints that can Constraint Violations
be violated in this operation are : Object and
Object-Relational
I Domain constraints can be violated if an attribute value is given Databases
Overview of Object
that does not appear in the corresponding domain or is not of the Database Concepts
Chapter 2
Yonas Y.
Outline
I Operation:
Insert < Alemayehu, Melaku, 999445777, 1960-04-05, M,
2800, 333445555, 4> into EMPLOYEE.
I Operation:
Insert < Alemayehu, Melaku, 999445777, 1960-04-05, M,
2800, 333445555, 4> into EMPLOYEE.
Result:This insertion satisfies all constraints, so it is acceptable.
AAiT - School of Electrical and Computer Engineering 54
The Delete Operation
Chapter 2
The Delete operation can violate only referential integrity. This occurs Yonas Y.
if the tuple being deleted is referenced by foreign keys from other tuples
Outline
in the database.
The Relational Data
Here are some examples. Model Concepts
Relational Model
I Operation: Concepts
Relational Model
Delete the WORKS ON tuple with ETinNo = 999887777 and Constraints and
Relational Database
Pno = 30. Schemas
Update Operations,
Result:This deletion is acceptable and deletes exactly one tuple. Transactions, and
Dealing with
Constraint Violations
Object and
Object-Relational
Databases
Overview of Object
Database Concepts
Extensible Markup
Language
Structured,
Semistructured, and
Unstructured Data
XML Hierarchical
(Tree) Data Model
The Update (or Modify) operation is used to change the values of one Object and
Object-Relational
or more attributes in a tuple (or tuples) of some relation R. Databases
The Update (or Modify) operation is used to change the values of one Object and
Object-Relational
or more attributes in a tuple (or tuples) of some relation R. Databases
The Update (or Modify) operation is used to change the values of one Object and
Object-Relational
or more attributes in a tuple (or tuples) of some relation R. Databases
I Operation:
Update the Dno of the EMPLOYEE tuple with TinNo =
999887777 to 1.
Result:Acceptable.
AAiT - School of Electrical and Computer Engineering 61
I Operation:
Update the Dno of the EMPLOYEE tuple with TinNo = Chapter 2
999887777 to 7. Yonas Y.
Result:Unacceptable, because it violates referential integrity.
Outline
Yonas Y.
Traditional data models and systems, such as relational, network, and
hierarchical, have been quite successful in developing the database Outline
technologies required for many traditional business database The Relational Data
Model Concepts
applications. Relational Model
Concepts
Relational Model
Constraints and
Relational Database
Schemas
Update Operations,
Transactions, and
Dealing with
Constraint Violations
Object and
Object-Relational
Databases
Overview of Object
Database Concepts
Extensible Markup
Language
Structured,
Semistructured, and
Unstructured Data
XML Hierarchical
(Tree) Data Model
Yonas Y.
Traditional data models and systems, such as relational, network, and
hierarchical, have been quite successful in developing the database Outline
technologies required for many traditional business database The Relational Data
Model Concepts
applications. Relational Model
Concepts
Relational Model
However, they have certain shortcomings when more complex database Constraints and
Relational Database
applications must be designed and implemented - for example, Schemas
Update Operations,
databases for engineering design and manufacturing (CAD/CAM and Transactions, and
Dealing with
CIM), scientific experiments, telecommunications, geographic Constraint Violations
information systems, and multimedia. Object databases were proposed Object and
Object-Relational
to meet some of the needs of these more complex applications. Databases
Overview of Object
Database Concepts
Extensible Markup
Language
Structured,
Semistructured, and
Unstructured Data
XML Hierarchical
(Tree) Data Model
Yonas Y.
Traditional data models and systems, such as relational, network, and
hierarchical, have been quite successful in developing the database Outline
technologies required for many traditional business database The Relational Data
Model Concepts
applications. Relational Model
Concepts
Relational Model
However, they have certain shortcomings when more complex database Constraints and
Relational Database
applications must be designed and implemented - for example, Schemas
Update Operations,
databases for engineering design and manufacturing (CAD/CAM and Transactions, and
Dealing with
CIM), scientific experiments, telecommunications, geographic Constraint Violations
information systems, and multimedia. Object databases were proposed Object and
Object-Relational
to meet some of the needs of these more complex applications. Databases
Overview of Object
Database Concepts
A key features of object databases are:
Extensible Markup
Language
I Give the designer power to specify both the structure of complex
Structured,
objects and the operations that can be applied to these objects. Semistructured, and
Unstructured Data
XML Hierarchical
I They are designed so they can be directly- or seamlessly - (Tree) Data Model
integrated with software that is developed using object-oriented
programming languages.
An object typically has two components: state (value) and behavior Yonas Y.
An object typically has two components: state (value) and behavior Yonas Y.
An object typically has two components: state (value) and behavior Yonas Y.
Yonas Y.
ODMS (Object Data Management System) provides a unique identity
to each independent object stored in the database. This unique identity Outline
Yonas Y.
ODMS (Object Data Management System) provides a unique identity
to each independent object stored in the database. This unique identity Outline
Yonas Y.
ODMS (Object Data Management System) provides a unique identity
to each independent object stored in the database. This unique identity Outline
the OID value of a particular object should not change. It is also Object and
Object-Relational
desirable that each OID be used only once; that is, even if an object is Databases
Overview of Object
removed from the database, its OID should not be assigned to another Database Concepts
Yonas Y.
ODMS (Object Data Management System) provides a unique identity
to each independent object stored in the database. This unique identity Outline
the OID value of a particular object should not change. It is also Object and
Object-Relational
desirable that each OID be used only once; that is, even if an object is Databases
Overview of Object
removed from the database, its OID should not be assigned to another Database Concepts
Most OO database systems allow for the representation of both objects Structured,
Semistructured, and
Unstructured Data
and literals (or values). Every object must have an immutable OID, XML Hierarchical
whereas a literal value has no OID and its value just stands for itself. (Tree) Data Model
Yonas Y.
An object definition language (ODL) that incorporates the preceding
type constructors can be used to define the object types for a particular Outline
Yonas Y.
An object definition language (ODL) that incorporates the preceding
type constructors can be used to define the object types for a particular Outline
Yonas Y.
Outline
Yonas Y.
Outline
Yonas Y.
Outline
standard for structuring and exchanging data over the Web. Overview of Object
Database Concepts
XML can be used to provide information about the structure and Extensible Markup
Language
meaning of the data in the Web pages rather than just specifying how Structured,
the Web pages are formatted for display on the screen. Semistructured, and
Unstructured Data
XML Hierarchical
(Tree) Data Model
Yonas Y.
Outline
Yonas Y.
Outline
I The labels or tags on the directed edges represent the schema
The Relational Data
names: the names of attributes, object types (or entity types or Model Concepts
classes), and relationships. Relational Model
Concepts
Relational Model
I The internal nodes represent individual objects or composite Constraints and
Relational Database
attributes. Schemas
Update Operations,
I The leaf nodes represent actual data values of simple (atomic) Transactions, and
Dealing with
Constraint Violations
attributes.
Object and
Object-Relational
Databases
Overview of Object
Database Concepts
Extensible Markup
Language
Structured,
Semistructured, and
Unstructured Data
XML Hierarchical
(Tree) Data Model
Yonas Y.
Outline
I The labels or tags on the directed edges represent the schema
The Relational Data
names: the names of attributes, object types (or entity types or Model Concepts
classes), and relationships. Relational Model
Concepts
Relational Model
I The internal nodes represent individual objects or composite Constraints and
Relational Database
attributes. Schemas
Update Operations,
I The leaf nodes represent actual data values of simple (atomic) Transactions, and
Dealing with
Constraint Violations
attributes.
Object and
Object-Relational
Databases
In addition to structured and semistructured data, a third category Overview of Object
Database Concepts
exists, known as unstructured data because there is very limited Extensible Markup
indication of the type of data. A typical example is a text document Language
Structured,
that contains information embedded within it. Semistructured, and
Unstructured Data
XML Hierarchical
(Tree) Data Model
Attributes in XML provide additional information that describes The Relational Data
Model Concepts
elements. Figure 2.4 shows an example of an XML element called Relational Model
Concepts
<Projects>. Relational Model
Constraints and
Relational Database
Schemas
Update Operations,
Transactions, and
Dealing with
Constraint Violations
Object and
Object-Relational
Databases
Overview of Object
Database Concepts
Extensible Markup
Language
Structured,
Semistructured, and
Unstructured Data
XML Hierarchical
(Tree) Data Model
Yonas Y.
Outline
Yonas Y.
Outline