Chapter 2
Database System Concepts
Chapter Objectives
• Learn the conceptual foundation of the relational
model
• Understand how relations differ from nonrelational
tables
• Learn basic relational terminology
• Learn the meaning and importance of keys, foreign
keys, and related terminology
• Understand how foreign keys represent
relationships
KROENKE and AUER - DATABASE CONCEPTS (7th Edition)
Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall
2-2
Database System Concepts
Database System Concepts refer to the fundamental
principles and structures that guide how databases are
designed, developed, and used. These include concepts
like:
a) Data: Information stored in a structured form (e.g.,
tables).
b) Database: A structured collection of data stored
electronically.
c) DBMS (Database Management System): A software
system that manages databases and allows users to
interact with data.
d) Database Model: The way data is logically structured
and represented (e.g., relational, NoSQL).
e) Queries: A way to retrieve or manipulate data using
languages like SQL.
Data Schema
A data schema defines the structure and organization of
data within a database. It is a blueprint that describes:
• Entity – A definable thing—such as a person, object,
concept or event, that can have data stored about it.
• Attribute – A property or characteristic of an entity.
Shown in column and rows
• Relationship – How entities act upon each other or are
associated with each other.
• Relation – a relation is a table with columns and rows
• Tuple – a tuple is a row of a relation
• Cardinality – the cardinality of a relation is the number of
tuples it contains
Example of a Relation
Entity
Characteristics of a Relation
1.
2.
3.
4.
5.
6.
7.
8.
Rows contain data about an entity.
Columns contain data about attributes of the entity.
Cells of the table hold a single value.
All entries in a column are of the same kind.
Each column has a unique name.
The order of the columns is unimportant.
The order of the rows is unimportant.
No two rows may be identical.
EmployeeNumber
FirstName
LastName
100
Mary
Abernathy
101
Jerry
Cadley
104
Alex
Copley
107
Megan
Jackson
2-6
Example of a Nonrelational Table
No two rows may be identical
EmployeeNumber
Phone
100
335-6421
101
215-7789
104
610-9850
100
335-6421
107
299-9090
LastName
Abernathy
Cadley
Copley
Abernathy
Jackson
2-7
E-R Diagram
• An Entity Relationship (ER) Diagram is a type of
flowchart that illustrates how “entities” such as
people, objects or concepts relate to each other
within a system.
• Also known as ERDs or ER Models, they use a
defined set of symbols such as rectangles,
diamonds, ovals and connecting lines to depict the
interconnectedness of entities, relationships and
their attributes.
2-8
E-R Diagrams
a)
b)
c)
d)
e)
Rectangles represent entity sets.
Diamonds represent relationship sets.
Lines link attributes to entity sets and entity sets to relationship
sets.
Ellipses represent attributes
a) Double ellipses represent multivalued attributes.
b) Dashed ellipses denote derived attributes.
Underline indicates primary key attributes
E-R Diagram With Composite, Multivalued, and
Derived Attributes
Composite
Multivalued
Derived
A Key
• A key is one (or more) column(s) of a
relation that is (are) used to identify a
row.
2-11
Uniqueness of Keys
Unique Key
Nonunique Key
Data value is unique
for each row.
Consequently, the
key will uniquely
identify a row.
Data value may be
shared among
several rows.
Consequently, the
key will identify a set
of rows.
2-12
A Composite Key
• A composite key is a key that
contains two or more attributes.
• For a key to be unique, it must often
become a composite key.
2-13
A Candidate Key
• A candidate key is called “candidate”
because it is a candidate to become
the primary key.
• A candidate key is a unique key.
2-14
A Primary Key
• A primary key is a candidate key chosen to
be the main key for the relation.
• If you know the value of the primary key,
you will be able to uniquely identify a
single row.
2-15
Surrogate Key
• A surrogate key is a unique, numeric
value that is added to a relation to
serve as the primary key.
• Surrogate key values have no
meaning to users and are usually
hidden on forms, queries, and reports.
• A surrogate key is often used in place
of a composite primary key.
2-16
Example of Surrogate Key
2-17
A Foreign Key
• To preserve relationships, you may
need to create a foreign key.
• A foreign key is a primary key from
one table placed into another table.
• The key is called a foreign key in the
table that received the key.
2-18
Foreign Key Example I
Project
ProjID
Manager
Primary Key
ProjName
MgrID
MgrID
MgrName
Foreign Key
2-19
Relationships Between Tables
• A table may be related to other tables.
• For example
– An Employee works in a Department
– A Manager controls a Project
2-20
Referential Integrity
• Referential integrity states that every
value of a foreign key must match a value
of an existing primary key.
• Example :
– If EmpID = 4 in EMPLOYEE has a DeptID
= 7 (a foreign key), a Department with
DeptID = 7 must exist in DEPARTMENT.
– The primary key value must exist before
the foreign key value is entered.
2-21
Example
Can be repeated
Unique
No duplication
2-22
The Null Value
• A Null value means that no data
was entered.
• This is different from a zero, space
character, or tab character.
2-23
The Problem of Null Values
• A Null is often ambiguous. It could
mean…
– The column value is not appropriate for
the specific row.
– The column value is not decided.
– The column value is unknown.
• Each may have entirely different
implications.
2-24
Database Architecture
Database architecture refers to the design and
structure of a database system, which includes:
• 1-Tier Architecture: The database is directly
available to the user (typically for local
applications).
• 2-Tier Architecture: The database resides on a
server, and a client application accesses the data
through
a
DBMS
(common
for
small
applications).
• 3-Tier Architecture: Involves a client (user
interface), application server (logic processing),
and database server (data storage). This is
common for enterprise systems.
2-25
1-Tier Architecture
• The
data
isn’t
frequently updated.
• Multiple users aren’t
accessing
the
database.
• A direct and simple
method of modifying
or accessing the
database is required
for
application
development.
2-26
2-Tier Architecture
•
•
•
•
It is possible to use it
simultaneously
by
multiple users, thus
making it suitable for
use
within
an
organization.
Due to the database
functionality
being
handled solely by the
server, it has a high
processing capability.
Direct connection and
enhanced performance
provide faster access to
the database.
Having two independent
layers makes it easier to
maintain
2-27
3-Tier Architecture
•
•
•
Database (Data) Tier:
This is where the actual
database is stored and
managed.
(Middle) Tier :This layer
contains the application
or
software
that
connects the user to the
database.
User
(Presentation)
Tier: This is the part the
user interacts with, like a
web interface or app.
The user doesn’t see or
know
about
the
database behind it.
2-28
3-Tier Architecture
User Tier
Database Tier
Middle Tier
2-29
END OF CHAPTER 2
2-30