Differences Between Three Levels of ANSI-SPARC Architecture
Differences Between Three Levels of ANSI-SPARC Architecture
ANSI-SPARC Architecture
1
Data Independence
• Logical Data Independence
– Refers to immunity of external schemas to
changes in conceptual schema.
– Conceptual schema changes (e.g.
addition/removal of entities).
– Should not require changes to external schema
or rewrites of application programs.
2
Data Independence
• Physical Data Independence
– Refers to immunity of conceptual schema to
changes in the internal schema.
– Internal schema changes (e.g. using different file
organizations, storage structures/devices).
– Should not require change to conceptual or
external schemas.
3
Data Independence and the ANSI-
SPARC Three-level Architecture
4
Data Model
5
Data Model
• Purpose
– To represent data in an understandable way.
6
Relational Systems
• Then, in 1970,E. F. Codd wrote “A Relational Model of
Data for Large Shared Databanks” and introduced the
relational model
• Information is stored as tuples or records in relations or
tables
• Most modern DBMS are based on the relational model
• The relational model covers 3 areas:
– Data structure
– Data manipulation
– Data integrity
Relational Model Terminology
• A relation is a table with columns and rows.
8
Relational Model Terminology
• Tuple is a row of a relation.
9
Instances of Branch and Staff Relations
10
Examples of Attribute Domains
11
Alternative Terminology for Relational
Model
12
Properties of Relations
• Relation name is distinct from all other relation
names in relational schema.
13
Properties of Relations
• Each tuple is distinct; there are no duplicate
tuples.
14
Candidate Keys
• A set of attributes in a
relation is called a candidate ID First Last
key if, and only if, S139 John Smith
– Every tuple has a unique S140 Mary Jones
value for the set of attributes S141 John Brown
(uniqueness) S142 Jane Smith
– No proper subset of the set
has the uniqueness property Candidate key: {ID}; {First,Last}
looks reasonable but we may get
(minimality)
people with the same name
{ID, First}, {ID, Last} and {ID,
First, Last} satisfy uniqueness,
but are not minimal
{First} and {Last} do not give
a unique identifier for each row
Choosing Candidate Keys
Department Employee
DID DName EID EName DID
13 Marketing 15 John Smith 13
14 Accounts 16 Mary Brown 14
15 Personnel 17 Mark Jones 13
18 Jane Smith NULL
Employee
{ID} is a Candidate Key for
ID Name Manager Employee, and {Manager} is
E1496 John Smith E1499 a Foreign Key, which refers
E1497 Mary Brown E1498 to the same relation - every
E1498 Mark Jones E1499 tuple’s Manager value is either
E1499 Jane Smith NULL NULL or matches an ID value
Referential Integrity
• When relations are • There are a number of
updated, referential options:
integrity can be violated – RESTRICT - stop the user from
• This usually occurs when a doing it
referenced tuple is updated – CASCADE - let the changes
flow on
or deleted
– NULLIFY - make values NULL
Referential Integrity - Example
• What happens if
– Marketing’s DID is changed to Department
16 in Department? DID DName
– The entry for Accounts is 13 Marketing
deleted from Department? 14 Accounts
15 Personnel
Employee
EID EName DID
15 John Smith 13
16 Mary Brown 14
17 Mark Jones 13
18 Jane Smith NULL
RESTRICT
• RESTRICT stops any action
that violates integrity Department
– You cannot update or delete DID DName
Marketing or Accounts 13 Marketing
– You can change Personnel as 14 Accounts
it is not referenced 15 Personnel
Employee
EID EName DID
15 John Smith 13
16 Mary Brown 14
17 Mark Jones 13
18 Jane Smith NULL
CASCADE
27
Views
• Base Relation
– Named relation corresponding to an entity in
conceptual schema, whose tuples are
physically stored in database.
• View
– Dynamic result of one or more relational
operations operating on base relations to
produce another relation.
28
Views
• A virtual relation that does not necessarily
actually exist in the database but is produced
upon request, at time of request.
29
Purpose of Views
• Provides powerful and flexible security
mechanism by hiding parts of database from
certain users.
30
Updating Views
• All updates to a base relation should be
immediately reflected in all views that
reference that base relation.
31