DB Concepts
DB Concepts
Lecture-2
1
Objectives
• Basic Concepts & Architecture
• History
• DBMS Benefits
• DBMS Abstraction
• Database Schema and State
2
History of Database Systems
• First-generation
o Hierarchical and Network
• Second generation
o Relational
• Third generation
o Object Relational
o Object-Oriented
3
Non-Relational Systems
• Database systems can be conveniently
categorized according to the data structures and
operators they present to the user
• The oldest system fall into three broad categories:
o Flat-File Systems
o Hierarchical Systems
o Network Systems
• We will not discuss these categories in great detail
as, although some are still used, they are obsolete
• We will focus on relational databases
4
Flat-File Systems
• The file system was a start. However, it was seriously inefficient
o Essentially, in order to find a record, someone would have
to read through the entire file and hope it would not be the
last record
o Imagine last record is the required one…
• What was needed, computer scientist thought, was a “card
catalog”, a mean to achieve the ability to efficiently access a single
record without searching the entire file to find it
• So the result was the “indexed file-oriented systems” in which a single
index file stored “key” words and pointers to records that were
stored else where. This made retrieval much more easier.
• But How???
o To find data, one needed only search for keys rather than
reading entire records.
o This was referred to as “flat-file systems”
5
Files, Records, and Fields
6
Indexed Files
7
Flat-File Systems (Cont…)
• Even with the benefits of indexing, the file-
oriented systems still suffered from problems
discussed before
o Data Redundancy - the same data might be stored
in different places
o Poor Data Control - redundant data might be slightly
different such as in the case when XYZ changes his
city and the change is only reflected in some of the
files containing his data
o Inability to Easily Manipulate Data - it was a tedious
and error prone activity to modify files by hand
8
Terms and Concepts
• Data Independence
o Physical representation and location of data and
the use of that data are separated
• The application doesn‟t need to know how or
where the database has stored the data, but just
how to ask for it
11
Objectives of Three-Level Architecture
• DBA should be able to change database
storage structures without affecting the user‟s
views
• Internal structure of database should be
unaffected by changes to physical aspects of
storage – change to a new storage device …
• DBA should be able to change conceptual
structure of database without affecting all
users
12
ANSI-SPARC Three-Level Architecture
13
ANSI-SPARC Three-Level Architecture
• External Level
o User‟s view of the database
o Describes that part of database that is relevant to a
particular user (e.g. different date representations,
age using DoB….)
o Includes only those entities, attributes, relationships
in “real world” that user is interested in …
• Conceptual Level
o Community view of the database
o Describes what data is stored in database and
relationships among the data
o Contains logical structure of entire DB as seen by
DBA 14
ANSI-SPARC Three-Level Architecture
o The conceptual level represents:
• All entities, attributes and their relationships
• The constraints on the data
• Semantic information about data
• Security and integrity information
• Internal Level
o Physical representation of the database on the
computer
o Describes how the data is stored in the database
o Internal level is concerned with:
• Storage space allocation for data
• Data compression and encryption techniques etc…
15
Differences between Three Levels of ANSI-
SPARC Architecture
16
-- Database Schema
• It is the description of a database
• It is specified during the database design and
is not expected to change frequently.
• It is represented as a diagram called schema
diagram.
o A schema diagram displays the structure of
each record type but not the actual
instance of a record.
• Each object in a schema is called a schema
construct.
17
Data Independence
• Logical Data Independence
o Refers to immunity of external schemas to changes in
conceptual schema
o Conceptual schema changes (e.g. addition/removal of
entities and/or relationships) should not require changes
to external schema or rewrites of application programs
18
Data Independence and the ANSI-SPARC
Three-Level Architecture
19
-- Database Schema
• It is the description of a database
• It is specified during the database design and
is not expected to change frequently.
• It is represented as a diagram called schema
diagram.
o A schema diagram displays the structure of
each record type but not the actual
instance of a record.
• Each object in a schema is called a schema
construct.
20
Schemas and Instances
• Similar to types and variables in programming languages
• Schema – the logical structure of the database – overall
description of the database
o E.g., the database consists of information about a set of
customers and accounts and the relationship between
them
o Three different types of schema according to levels of
abstraction of three-level architecture …
o Sub-Schemas/external schemas: there may be several
of these at the view level, each providing a different
view of database
o Physical/internal schema: database design at the
physical level – complete description of internal model:
definition of stored records, methods of representations, data
fields, indexes etc…
21
Schemas and Instances
o Logical/conceptual schema: database design at the
logical level - describing all entities, relationships, ICs
etc…
22
--- Example of a Database Schema Diagram
23
-- Database State
24
--- Example of a Database State
25
Database Languages
• Data Definition Language (DDL)
o Allows the DBA or users to:
• describe and name entities, attributes, and
relationships required for the application
• define any associated integrity and security
constraints
o Is used to define a schema or to modify an existing
one …
o It can not be used to manipulate data
o The result of compilation of DDL statements is a set
of tables stored in special files – System Catalog/
Data Dictionary
26
Database Languages
• Data Manipulation Language (DML)
o Provides basic data manipulation operations of data
held in the database (insertion, modification,
deletion and retrieval of data…)
o Part of DML involving data retrieval is called „Query
Language‟
• Procedural DML
o Allows user to tell system exactly how to manipulate
data (what data is required and how to retrieve,
e.g. PL/SQL)
• Non-Procedural DML
o Allows user to state what data is needed rather than
how it is to be retrieved (e.g. SQL)
27
Database Languages