Data Base Level of SPRC
Data Base Level of SPRC
Data Base Level of SPRC
Systems
Lecture 2
Ms. Qudsia Yousaf
Spring 2024
Three-Level
ANSI-SPARC
Architecture
American National
Standards Institute (ANSI)
Users should not have to deal directly with physical database storage details, such as
indexing or hashing. In other words, a user’s interaction with the database should be
independent of storage considerations.
The Database Administrator should be able to change the database storage structures
without affecting the users’ views.
The internal structure of the database should be unaffected by changes to the physical
aspects of storage, such as the changeover to a new storage device.
The DBA should be able to change the conceptual structure of the database without
affecting all users.
5
External View
The users’ view of the database. This level describes only that part of the
database that is relevant to each user.
Different views may have different representations of the same data. For
example, one user may view dates in the form (day, month, year), while
another may view dates as (year, month, day).
• Some views might include derived or calculated data (data not actually
stored in the database as such, but created when needed. E.g. age of a
member of staff)
External schema evolves as user needs are modified over time.
6
The community view of the database. This level
describes what data is stored in the database and the
relationships among the data.
This level contains the logical structure of the entire
database as seen by the DBA.
It is a complete view of the data requirements of the
organization that is independent of any storage
Conceptual considerations. It represents
Level All entities, their attributes, and their relationships and the
constraints on the data;
Semantic information about the data;
Security and integrity information.
Conceptual level supports each external view, in that any
data available to a user must be contained in, or
derivable from, but No storage considerations, such as
the number of bytes occupied.
7
The physical representation of the database on the
computer. This level describes how the data is stored
in the database. It is concerned with:
8
First Name: Rana Name:
Last Name: Aslam R. Aslam
Date of Birth: Age: 24y, 10d
12 Sep, 1970 Dept: Sales
01110011010011100101001010100
101
9
The overall description of the database is called the database schema. A
database schema is a predefined, structured framework that defines the
organization, relationships, and constraints of data within a database.
There are three different types of schemas in the database.
At the highest level, we have multiple external schemas
that correspond to different views of the data.
At the conceptual level,
Database we have the conceptual schema, which describes all the entities, attributes,
Schema and relationships together with integrity constraints.
At the lowest level of abstraction we have the internal schema,
which is a complete description of the internal model, containing the
definitions of stored records, the data fields, and the indexes and storage
structures used.
There is only one conceptual schema and one internal schema per
database.`
The database schema is specified during the database design process
and is not expected to change frequently. However, the actual data10in the
database may change frequently.
Difference
between
Three-levels
11
Example: University Database
Students(sid: string
name: string,
login: string,
Conceptual schema: age: integer)
Courses(cid: string,
cname:string,
credits:integer)
Enrolled(eid:string,
cid:string,
grade:string)
13
Instance
www.cs.gsu.edu/
.../
CSCI%203360%20Database%20Syst
ems/
Chapt
er%20.. 14
Data
Independence
15
A major objective for the three-level architecture is
to provide data independence, which means that
upper levels are unaffected by changes to lower
levels. There are two kinds of data independence:
16
The Data Definition Language
A language that allows the DBA/user to describe and name
the entities, attributes, and relationships required for the
application, together with any associated integrity and
security constraints.
Data Manipulation Language (DML)
Database Provides basic data manipulation operations on data held in
the database.
Languages Procedural DML
A language that allows the user to tell the system what data
is needed and exactly how to retrieve the data.
Specify what data is required and how to access that data
• Non-Procedural DML
Allows user to state what data is needed rather than how it is
to be retrieved.
Specify what data is required but not specify how to retrieve
14
Procedural DML
CREATE PROCEDURE CalculateOrderTotal
@OrderId INT,
@TotalAmount DECIMAL(10, 2) OUTPUT
AS
BEGIN
DECLARE @ItemCount INT
DECLARE @UnitPrice DECIMAL(10, 2)
DECLARE @Discount DECIMAL(5, 2)
-- Calculate total number of items and their unit price for the given order
SELECT @ItemCount = COUNT(*), @UnitPrice = SUM(UnitPrice)
FROM OrderDetails
WHERE OrderId = @OrderId
-- Determine discount based on the total number of items
IF @ItemCount > 10
SET @Discount = 0.1
ELSE
SET @Discount = 0
-- Calculate total amount after discount
SET @TotalAmount = @UnitPrice * (1 - @Discount)
END
Non-Procedural DML
SELECT OrderId,
SUM(UnitPrice * Quantity) * (1 - CASE WHEN COUNT(*) >
10 THEN 0.1 ELSE 0 END) AS TotalAmount
FROM OrderDetails
WHERE OrderId = 123
GROUP BY OrderId;
Fourth Generation Languages (4GLs)
There is no agreement about what constitutes a 4GL.
14
Fourth-generation languages encompass:
Presentation languages, such as query
Database languages and report generators;
Entity-Relationship (ER)
Object-Oriented
24
The ER model is primarily used to represent
the structure of data in a database system. It
focuses on entities, their attributes, and the
relationships between entities.
Object Based
Data Models Object-Oriented data model extends the
definition of an entity to include not only the
attributes that describe the state of the object
but also the actions that are associated with
the object, that is, its behavior.
The object is said to encapsulate both state
and behavior.
25
Object Oriented
Model
ER Model
In a record-based model, the database consists of
a number of fixed-format records possibly of differing
types.
Each record type defines a fixed number of fields,
each typically of a fixed length.
Record Based There are three principal types of record-based
Data Models logical data model
used to describe Relational data model
data at the
Network data model
conceptual and
external levels and the Hierarchical data model.