Database System Concepts & Architecture - Conceptual Data Modeling and Database Design
Database System Concepts & Architecture - Conceptual Data Modeling and Database Design
Fundamentals of Database
DATABASE SYSTEM CONCEPTS & ARCHITECTURE
Level of Abstraction
Fundamentals of Database
CONT’D…
Data model: a collection of concepts that can be used to describe the structure of a database.
Basic operations
1. High-level or Conceptual data models: provide concepts that are close to the way many users
perceive data: uses
Entities
Attributes
Relationships
Fundamentals of Database
CONT’D…
widely used relational data model, constraints, operations and languages (standard
SQL).
3. Low-level or Physical data models: provide concepts that describe the details
of how data is stored on the computer storage media. (computer specialists, not for
end users)
record formats, record orderings, and access paths (search by Index or Key word)
Fundamentals of Database
CONT’D…
Schema
Fundamentals of Database
CONT’D…
schema diagram
Fundamentals of Database
RELATION SCHEMA
Example:
Fundamentals of Database
In a given database state, each schema construct has its own current set of instances; for
example, the STUDENT construct will contain the set of individual student entities
(records) as its instances.
Fundamentals of Database
THE THREE LEVEL OF ABSTRACTION (THE
THREE-SCHEMA ARCHITECTURE)
CONT’D…
Goal: separate the user application from physical database
2. Conceptual level: hides the detail of physical storage structure and focus on describing entities,
data type etc. what data is stored
3. External level: describes the part of the DB that the user interested in and hide the rest of the
database from the user group.
Fundamentals of Database
CONT’D…
Data Independence:
Classification of DBMSs
Fundamentals of Database
READING ASSIGNMENT
Fundamentals of Database
OUTLINE
Basic concepts:
Relation
Entity, attributes
constraints
The data elements in each row represent certain facts that correspond to a real-world entity or
relationship
Relationships: among two or more entities represents an association among the entities.
Each column has a column header that gives an indication of the meaning of the data items
In the formal model, the column header is called an attribute name (or just attribute)
Fundamentals of Database
EXAMPLES OF A RELATION
Fundamentals of Database
CONT’D…
A row in the CUSTOMER relation is a 4-tuple and would consist of four values, for example:
<“632895”, "John Smith", "101 Main St. Atlanta, GA 30332", "(404) 894-2000">
Fundamentals of Database
CONT’D…
A domain D Examples:
A domain has a logical definition:
Example: “USA_phone_numbers” are the set of 10 digit phone numbers valid in the U.S.
A domain also has a data-type or a format defined for it.
The USA_phone_numbers may have a format: (ddd)ddd-dddd where each d is a decimal digit.
Dates have various formats such as year, month, date formatted as yyyy-mm-dd, or as dd
mm,yyyy etc.
Fundamentals of Database
PROPERTIES OF RELATIONS
Each value in a tuple is an atomic value; that is, it is not divisible into
components within the framework of the basic relational model. Hence,
composite and multi value attributes are not allowed
NULL values, which are used to represent the values of attributes that may be
unknown or may not apply to a tuple.
Fundamentals of Database
RELATIONAL MODEL CONSTRAINTS
Constraints are conditions that must hold on all valid relation states.
Fundamentals of Database
KEY
CONSTRAINTS
All tuple in a relation must be distinct. This means that no two tuple can have the
same combination of values for all their attributes
Suppose that we denote one subset of attributes by SK; then for any two distinct
tuple t1 and t2 in a relation state r of R, we have the constraint that:
t1[SK]≠t2[SK]
Any such set of attributes SK is called a super key of the relation schema R
Fundamentals of Database
CONT’D…
A super key SK specifies a uniqueness constraint that no two distinct tuples in any
state r of R can have the same value for SK.
A super key can have redundant attributes, however, so a more useful concept is
that of a key, which has no redundancy
1. Two distinct tuples in any state of the relation cannot have identical values for
(all) the attributes in the key. This first property also applies to a super key.
Fundamentals of Database
CONT’D…
2. It is a minimal super key—that is, a super key from which we cannot remove any
attributes and still have the uniqueness constraint in condition 1 hold. This property
is not required by a super key. Hence a key is also a super key but not vice versa.
Consider the STUDENT relation .
The attribute set {Ssn} is a key of STUDENT because no two student tuples can
have the same value for Ssn. Any set of attributes that includes Ssn—for example,
{Ssn,Name,Age}—is a super key
Fundamentals of Database
CONT’D…
The value of a key attribute can be used to identify uniquely each tuple in the relation.
For example, the Ssn value 305-61-2435 identifies uniquely the tuple corresponding to
Benjamin Bayer in the STUDENT relation
a relation schema may have more than one key. In this case, each of the keys is called a
candidate key. For example, the CAR relation has two candidate keys: License_number
and Engine_serial_number.
It is common to designate one of the candidate keys as the primary key of the relation.
Fundamentals of Database
CONT’D…
Notice that when a relation schema has several candidate keys, the choice of one to
become the primary key is somewhat arbitrary; however, it is usually better to choose
a primary key with a single attribute or a small number of attributes. The other
candidate keys are designated as unique keys, and are not underlined.
Fundamentals of Database
ENTITY INTEGRITY
CONSTRAINT
The entity integrity constraint states that no primary key value can be NULL. This
is because the primary key value is used to identify individual tuple in a relation.
Having NULL values for the primary key implies that we cannot identify some tuple
Fundamentals of Database
REFERENTIAL INTEGRITY
CONSTRAINT
The referential integrity constraint is specified between two relations and is used to maintain the consistency among
tuple in the two relations.
Informally, the referential integrity constraint states that a tuple in one relation that refers to another relation must refer to
an existing tuple in that relation.
Foreign key
The conditions for a foreign key, given below , specify a referential integrity constraint between the two relation schemas
R1 and R2.
A set of attributes FK in relation schema R1 is a foreign key of R1 that references relation R2 if it satisfies the following
rules:
Fundamentals of Database
CONT’D…
1. The attributes in FK have the same domain(s) as the primary key attributes PK of R2; the
attributes FK are said to reference or refer to the relation R2.
2. A value of FK in a tuple t1 of the current state r1(R1) either occurs as a value of PK for
some tuple t2 in the current state r2(R2) or is NULL.
In the former case, we have t1[FK] = t2[PK], and we say that the tuple t1 references or
refers to the tuple t2.
In this definition,R1 is called the referencing relation and R2 is the referenced relation. If
these two conditions hold, a referential integrity constraint from R1 to R2 is said to hold.
Fundamentals of Database
CONT’D…
• Draw relational database schema that we call
COMPANY = {EMPLOYEE, DEPARTMENT, DEPT_LOCATIONS, PROJECT}
Fundamentals of Database
CONT’D…
• Draw relational database schema that we call COMPANY = {EMPLOYEE, DEPARTMENT,
DEPT_LOCATIONS, PROJECT, WORKS_ON, DEPENDENT}
• EMPLOYEE (A1,A2… An)
• DEPARTMENT,
• DEPT_LOCATIONS,
• PROJECT,
• WORKS_ON,
• DEPENDENT
Fundamentals of Database
CONT’D…
All the above constraint also called state constraints because they define the constraints that a valid
state of the database must satisfy.
Fundamentals of Database
RELATIONAL DATABASES AND RELATIONAL DATABASE SCHEMAS
The definitions and constraints we have discussed so far apply to single relations and
their attributes.
Fundamentals of Database
CONT’D…
A database state that does not obey all the integrity constraints is called an invalid
state, and a state that satisfies all the constraints in the defined set of integrity
constraints IC is called a valid state.
Each relational DBMS must have a data definition language (DDL) for defining a
relational database schema.
Current relational DBMSs are mostly using SQL for this purpose
Fundamentals of Database
UPDATE OPERATIONS AND CONSTRAINT VIOLATION
The operations of the relational model can be categorized into retrievals and
updates
The three basic operations that can change the states of relations in the
database: Insert, Delete, and Update (or Modify). They insert new data,
delete old data, or modify existing data records
Fundamentals of Database
CONT’D…
The Insert operation provides a list of attribute values for a new tuple t that is to be inserted
into a relation R
Insert can violate any of the four types of constraints discussed in the previous section.
Domain constraints can be violated if an attribute value is given that does not appear in the
corresponding domain or is not of the appropriate data type.
Key constraints can be violated if a key value in the new tuple t already exists in another tuple
in the relation r(R).
Entity integrity can be violated if any part of the primary key of the new tuple t is NULL.
Fundamentals of Database
CONT’D…
Referential integrity: It can be violated if the value of any foreign key in t refers
Result: This insertion violates the referential integrity constraint specified on Dno in EMPLOYEE
because no corresponding referenced tuple exists in DEPARTMENT with Dnumber = 7
If an insertion violates one or more constraints, the default option is to reject the insertion and
correctly input again.
Fundamentals of Database
DELETION OPERATION
The Delete operation can violate only referential integrity
This occurs if the tuple being deleted is referenced by foreign keys from other tuple in the
database
Operation
Result: This deletion is not acceptable, because there are tuple in WORKS_ON that refer to this
tuple. Hence, if the tuple in EMPLOYEE is deleted, referential integrity violations will result.
Fundamentals of Database
CONT’D…
Update Operation
Updating an attribute that is neither part of a primary key nor of a foreign key
usually causes no problems; the DBMS need only check to confirm that the new
value is the correct data type and domain.
Fundamentals of Database
RELATIONAL DBMS
RDBMS is the basis for SQL, the data in RDBMS is stored in database objects called tables .
In addition, several open source systems, such as My SQL and Postgre SQL,are available
Fundamentals of Database