0% found this document useful (0 votes)
16 views27 pages

STADVDB Slides 01a - Relational Database (Review)

The document provides an overview of the relational database model, detailing its structure, components, and integrity constraints. It explains key concepts such as relations, tuples, attributes, and the importance of integrity constraints in maintaining data consistency. Additionally, it discusses the role of Database Management Systems (DBMS) in managing databases and ensuring controlled access to data.

Uploaded by

joe goldberg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views27 pages

STADVDB Slides 01a - Relational Database (Review)

The document provides an overview of the relational database model, detailing its structure, components, and integrity constraints. It explains key concepts such as relations, tuples, attributes, and the importance of integrity constraints in maintaining data consistency. Additionally, it discusses the role of Database Management Systems (DBMS) in managing databases and ensuring controlled access to data.

Uploaded by

joe goldberg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Relational Model

A Review
Advanced Database Systems
1
Relational Database Model
Tuples
(Rows)
Constraints
Tables
Not Null,
Check,
Attributes References ..
(Columns) .
Relational
Database Keys
Data Primary,
Types Foreign
Operations 2

Joins, Selection, Projection, …


Relation (Informal Definition)
• A logical structure with columns and rows
• Columns  Attributes
• Domain  Allowed values for the attributes
• Rows  Tuple
• Degree  Number of Attributes in a
Relation
• Cardinality  Number of Tuples in a Relation
• Relation Instance  Set containing all tuples

3
Relation Instance: Examples

Connolly & Begg, 2015


Relation (Formal Definition)
• The Schema (or description) of a Relation R:

R(A1, A2, .., An)

• R  Name of the relation


• Ai  Attribute of the relation

• Example
Branch(branchNo, street, city, postcode)
• Branch is the name of the relation 5

• It has four attributes: branchNo, street, city, postcode


Relation (Formal Definition)
• Tuple
• An ordered set of values enclosed in angled brackets <
>
• Each value is derived from an appropriate domain
<108, “Taft Avenue”, “Manila”, 1004>

• A Relation is a set of such tuples (rows)


• The tuples in a relation are not ordered

6
Relation (Formal Definition)
• Domain – can be defined
• Logically
• postcode contains the set of 4-digit postal code valid in
the Philippines
• Based on data type and/or format
• phoneno has the format (aaa) ddd-dddd where aaa is the
area code, ddd-dddd is the 7-digit number
• birthdate has the data type “DATE”

Elmasri & Navathe, 2016


Relational Database
• A relational database schema S
• A set of relation schemas Ri and a set of
integrity constraints IC
• S = {R1, R2, .., Rn}, IC.

• A relational database instance DB


• a set of relation instances
• DB = {r1, r2, .., rn}
• Each ri satisfies the integrity constraints specified
in IC
8
Properties of a Relation
• Each relation name in a relational DB is distinct
• Each cell of a relation contains exactly one atomic
(single) value
• An attribute name in a relation is distinct from
any attribute names of the same relation
• The value of an attribute must belong to the
domain of the attribute
• The order of attributes in R is not significant
• Each tuple of a relation is distinct, no duplicate
tuples must exist 9

• The order of tuples in R is not significant


Integrity Constraints
• Specifies which values are permissible and which are not in the
database
• Conditions that must hold on all valid relation instances/states
• Guard against accidental damage to the database
• Authorized changes to the database should not result in a loss of
data consistency

10

Elmasri & Navathe, 2016; Silberschatz, Korth & Sudarshan, 2019


Integrity Constraints
• Three main types:
• Inherent or Implicit constraints – based on the data model itself, e.g.,
the relational model requires each value of an attribute to be atomic
• Schema-based or Explicit constraints – expressed in the schema
using facilities provided by the model, e.g., the cardinality or
structural constraint in the conceptual (ER) model
• Application-based on Semantic constraints – beyond the expressive
power of the model and must be specified and enforced by the
application programs
• Examples:
• A checking account must have a balance greater than PhP10,000.00
• A bank employee must have an hourly salary of at least P620 11
• A customer must have a (non-null) phone number

Elmasri & Navathe, 2016; Silberschatz, Korth & Sudarshan, 2019


Relational Integrity
Constraints
• Domain Constraint
• The value of each attribute must be an atomic value
from its domain

AUTHOR idno fname lname address


95023 Milan Milenkovic NY
95924 C. J. Date California
95025 Ramez Elmasri Texas

idno : char(5); /* id numbers */


fname : char(20); /* first names */
lname : char(20); /* last names */
address : char(50); /* addresses */
12
Gender: “M” or “F”
Genre: “SF”, “F”, “BIO”, “C”, …
Relational Integrity
Constraints
• Key Constraint
• Prevents duplicate tuples (rows) from occurring in a
relation

• Candidate Key
• A set of at least 1 attribute that uniquely identifies a tuple in
a relation
• All relations have a default SuperKey which is the set of all
attributes

• Primary Key
• The candidate key that has been selected to uniquely
identify tuples within a relation
13
Relational Integrity
Constraints
• NULL values
• Represents a value for an attribute that is currently
unknown or is not applicable for a tuple
• Not the same as zero or spaces

Student ID Name Degree Major


10900001 Thomas Conolly BSCS ST
10900002 Carolyn Begg BSCS IST
10900003 Ramez Elmasri BSCS NULL
10900004 Shamkant Navathe BSCS NE
14
Relational Integrity
Constraints
• Entity Integrity
• No attribute of a Primary Key can be NULL.

Student ID Name Degree Level

NULL ✗ Thomas Conolly BSCS 1

NULL ✗ Carolyn Begg BSCS 2

10900001 Ramez Elmasri BSCS 3


10900002 Shamkant Navathe BSCS 4

15
Relational Integrity
Constraints
• Referential Integrity
• Foreign Key
• A set of at least 1 attribute within one relation that matches
the candidate key of another (possibly the same) relation

• When a Foreign Key exists, the value must match a


candidate key value of some tuple in its home relation.
• In some cases, a Foreign Key can have a NULL value.

Student ID Guardian Relationshi Contact No


p
10900001 Milan Kovic Aunt 123-4567

10900003 ✗ C.J. Date Uncle 456-7890


16
NULL Ben Bayer Father 765-4321
Database Management
System (DBMS)

17
Requirements of the DB Approach

• A central repository of shared data


• A controlling agent to manage the creation,
update and retrieval of data
• A standard and convenient storage facility

What can satisfy all these


three requirements?
18
Hoffer, Prescott & Topi (2013)

Database Management System


 A software system that is used to create, maintain, and provide
controlled access to user databases

 Central  Controlled
Order Filing  Shared  Managed
System

Central database
Invoicing
DBMS
System Contains employee,
order, inventory,
Payroll pricing, and
System customer data

19
DBMS manages data resources like an
Operating system manages hardware resources
Elmasri & Navathe (2016)

Database Environment

Controlled Access:
- Security
- Data integrity
- Concurrency
- Recovery
- Catalog
20
Connolly & Begg (2015)

Components of the DBMS

From PC to a DBMS, OS, Processes &


network of Application Business Rules
computers Programs applied in the
design and use of
the Database
21
Important Elements of a DBMS

INTRODB Advanced Topics


• System Catalog • Security & Authorization
• MetaData • Transaction Processing
• View Mechanism • Query Optimization
• Structured Query Language • Concurrency Control
• Data Definition Language • Backup and Recovery
• Data Manipulation
Language
22
Connolly & Begg (2015)

Components of a DBMS

23
Connolly & Begg (2015)

Database Manager

24
Connolly & Begg (2015)

System Catalog
• Repository of information (MetaData) describing the data in
the database
• Typically stores
• names, types, and sizes of data items;
• constraints on the data;
• names of authorized users;
• data items accessible by a user and the type of access;
• usage statistics

25
Relational Language
- SQL
A Review
Advanced Database Systems
26
References
Chapter 2: Database Environment
Chapter 3: Database Architectures
Chapter 4: The Relational Model
T. Connolly and C. Begg. (2015). Database Systems: A Practical Approach to
Design, Implementation, and Management, 6th Edition. Harlow, Essex:
Addison-Wesley

Chapter 1: Databases and Database Users


Chapter 5: Relational Data Model and Relational Database Constraints
R. Elmasri and S. Navathe. (2016). Fundamentals of Database Systems, 7th
Edition. Boston: Pearson/Addison Wesley

Chapter 1: The Database Environment and Development Process


27
Chapter 2: Introduction to the Relational Model
A. Silberschatz, H. Korth and S. Sudarshan. (2019). Database System
Concepts, 7th Edition. McGraw-Hill Book Co.

You might also like