Lecture 02 - Database Architecture

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 61

‫َّر‬ ‫َّر‬

‫ِبْس اللِه ال ْحٰمِن ال ِحْي‬


‫ِّب اْش ِم ْح ي ْد ي ِّس ْر ي ِمَأ‬
‫َر ِل َص ِر َو َي ِل ْم ِري‬ ‫َر‬
‫َو اْح ُلْل ُع ْقَد ًة ِم ْن ِلَس اِني َيْفَقُهوا َقْو ِلي‬
Database Architecture
Lecture # 02

Course Instructor: Samra Kanwal


Lecture Outline

▰ Introduction
▰ Database Architecture Type
▰ Objective of Three Level Architecture
▰ The Three Level Architecture
▰ Data Model

3
Database Architecture types

▰ There are three types of database


architectures:
▻ 1-tier DBMS
▻ 2-tier DBMS
▻ 3-tier DBMS

5
1-tier DBMS Architecture

▰ In this architecture, the database is directly available to


the user. It means the user can directly save data in
DBMS and can use it.
▰ The 1-Tier architecture is used for the development of
the local application, where programmers can directly
communicate with the database for quick response.

6
2-tier DBMS Architecture

▰ 2-tier DBMS architecture client directly communicates


with the database server through ODBC.
▰ An application interface which is called ODBC (Open
Database Connectivity) an API that allows the client-side
program to call the DBMS.

7
2-tier DBMS Architecture

8
3-tier DBMS Architecture

▰ 3-tier DBMS architecture is the most commonly used


architecture for web applications.

User

9
3-tier DBMS Architecture

▰ It is an extension of the 2-tier architecture. In the 2-tier


architecture, we have an application server that can be
accessed programmatically to perform various
operations like validation, calculation and manipulation
of data.

10
Levels of Abstraction

▰ To ease the user interaction with the database, the


developers hide internal irrelevant details from users.
This process of hiding irrelevant details from the user
is called data abstraction.
▰ Three levels of Abstraction
▻ Also known as Three-Level Architecture / Three
Schemas / Three Models

11
3 Levels of Architecture

▰ Three Levels of abstraction of a database


▻ View Level (External Level)
▻ Logical Level (Conceptual Level – What data
is stored)
▻ Physical Level (Internal Level – How data is
stored)
Higher abstraction

Lower abstraction
14
3 Levels of Architecture

▰ The ANSI-SPARC architecture is divided into


3 levels

▻ The External Level


▻ The Conceptual Level
▻ The Internal Level

15
ANSI-SPARC Three-Level
Architecture

16
External View

▰ Highest level of data abstraction. This describes the


user interaction with the database system.
▰ At the external/view level, users just interact with the
system with the help of GUI and enter the details on
the screen, they are not aware of how the data is
stored and what data is stored; such details are
hidden from them.
▰ External level consists of many different external
views
▰ Each external view may have different
representations
17
External View

▰ External views are described in External schemas


which are written in the Data Definition Language
▻ Each user’s schema provides a complete description
of the user’s view
▰ External sachems are used to create GUI.
▰ User only interacts with certain entities.
▰ User will be unaware of other entities, attributes
and relationships.
▰ Allows to see only the data of interest to them.

18
External View

19
Conceptual Model

▰ Logical level: This is the middle level of 3-level data


abstraction architecture. It describes what data is
stored in the database.
▰ It describes what will be the entities, what will be their
attributes and the relationships between them.
▰ Middle level that contains the entire information of the
database (A representation of the entire information,
content of the database)
▻ e.g. DBA has this view
▰ Complete model of working organization

20
Conceptual Model

▰ Complete logical model


▻ Entities, attributes, relationships, constraints on
data, semantic information, security and integrity
▰ Conceptual model supports external views
▰ Conceptual model is relatively constant
▻ DBA is responsible for designing it
▻ The conceptual model can be expanded
▰ It is written in DDL, stored in a data dictionary and
compiled by DBMS

21
Conceptual Model

▰ All Structural details are known at this level.


▻ Tables, table contents.
▻ Table’s connections.
▻ Views and users.
▻ Constraints etc.

22
Physical Model

▰ This is the lowest level of data abstraction. It


describes how data is stored in the database and
what type of data will be stored.
▻ Also called storage view
▰ Let’s say we are storing customer information in a
customer table. At the physical level, these records
can be described as blocks of storage (bytes,
gigabytes, terabytes, etc.) in memory.
▰ Simply, it is managed by OS but under the instruction
of DBMS

23
Physical Model

▰ Physical implementation of database


▻ Includes data structures and file organization
▻ Works with OS
▻ To lay out data on the storage devices
▻ Build Indexes
▻ Set the pointers
▰ A description of how information is stored on physical
devices, for example:
▻ Hard drives, Tape devices, Compact disks, DVDs,
etc. 24
Differences between Three Levels
of
ANSI-SPARC Architecture

25
Example 2- Differences between Three Levels
of
ANSI-SPARC Architecture

26
Purpose of Three-Level
Architecture

▰ User’s view
▻ Requirements of each user varies.
▻ All users should be able to access the same
data.
▻ A user’s view is immune to changes made in
other
▻ The user should not need to know physical
database storage details.

27
Purpose of Three-Level
Architecture

▰ DBA’s view
▻ DBA should be able to change database storage
structures without affecting the users’ views.
▻ The internal structure of the database should be
unaffected by changes to physical aspects of
storage.
▻ DBA should be able to change the conceptual
structure of the database without affecting all
users.

28
Mapping

▰ Mapping is the process of converting one level


to another level. In this process, the data at one
level is related to the data at another level.
▰ Mapping defines the correspondence between
the
▻ External mapping and conceptual mapping
▻ Conceptual mapping and the internal
mapping

29
Mapping

User A2 User B1 User B2 User B3


User A1

External External External External


Schemas and
Schema A view B Schema B
mappings view A
built and
maintained External\Conceptual External\Conceptual
by the Mapping A Mapping B
Database
Admin. Conceptual view DBMS
Conceptual
(DBA) Schema

Conceptual\internal
Mapping

Stored Database( Internal View) 30


Conceptual/Internal Mapping

▰ Defines correspondence between conceptual and


internal schemas.
▰ Specifies how conceptual records are represented
on the internal level.
▰ If structure of the DB is changed Conceptual/internal
mapping is changed accordingly
▰ DBA makes these changes
▰ Effects of such changes are isolated between the
two schemas.

31
External/Conceptual Mapping

▰ Defines correspondence b/w external and


conceptual schemas.
▰ Many conceptual fields can form one external view
etc.

32
Instances and Schemas

▰ Each level is defined by a schema, which defines the


data at the corresponding level
▻ A logical schema defines the logical structure of
the database (set of customers and accounts and
the relationship between them)
▻ A physical schema defines the file formats and
locations
▰ A database instance refers to the actual content of
the database at a particular point in time. A database
instance must conform to the corresponding schema

33
Three Level Architecture

Advantage

Data Independence

Logical data Physical data


Independence Independence

34
Data Independence

▰ The separation of data and application program is


called as data independence.
▰ It is an important feature of DBMS. It is the most
important advantage of three level architecture.
▰ Another major advantage is that any change in lower
level architecture does not affect the structure or
functionality of upper levels.
▰ Data independence enables the user to change the
structure of a database without changing the
application programs or the way users access the
data.
35
Data Independence

▰ Data independence can be classified into two type


based on the level at which the independence is
obtained.
▻ Logical Data Independence
▻ Physical Data Independence

36
Data Independence

▰ Logical Data Independence


▻ Refers to immunity of external schemas to
changes in conceptual schema.
▻ Conceptual schema changes (e.g.
addition/removal of records).
▻ Should not require changes to external schema or
rewrites of application programs.

37
Data Independence
Logical Data Independence

▰ Enables the user to change the conceptual level/logical level


without changing the external level/view level.

▰ The changes that may be performed at logical level without


changing the external level are as follows:

▻ Adding or removal of entities or relationships

▻ Adding a field to the database

▻ Removing a field from database

38
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).
▻ If someone changes his HDD from FAT32 to
NTFS! Should not require change to conceptual or
external schemas.

39
Data Independence
Physical Data Independence

▰ enables the user to change the internal level/physical


level without changing the conceptual level/logical
level.
▰ In DBMS, a physical structure of database may
change without changing application programs or
altering the user’s view of data
▻ i.e. if the physical structure changes, DBMS is
aware of these changes, but still provides the
same logical view.

40
Data Independence
Physical Data Independence

▰ The changes that may be performed at physical level


without changing the logical level view are as follows:
▻ Changing file organization or storage structures
▻ Using different storage devices
▻ Modifying indexes
▻ Changing the access method
▻ Changing data structure

41
Data Independence and the ANSI-
SPARC

▰ Three-Level Architecture

42
Model

▰ Model: Refer to the permanent model of structure, not


data stored
▰ Permanent Structure: Intension of database or database
schema
▰ Information stored: Extension of database or database
instance
▰ Database model: collection of tools
▻ Diagrams
▻ Specialized:
▻ vocabulary to describe structure of database

43
Data Models

▰ Data Model
▻ A collection of concepts that can be used to describe
the structure of a database
▻ By the structure we mean the data types,
relationships, and constraints that should hold on the
data
▻ Also includes basic operations for specifying
retrievals and updates on the database
▻ It is becoming more common to include concepts to
specify the dynamic aspect or behavior of a database
application
44
Parts of Data Model

▰ Structural Part:
▻ It consists of a set of rules. These rules specify how a
database can be developed
▰ Manipulative Part:
▻ It defines the types of operations that can be
performed on data. The operations include updating
or retrieving data from database and changing the
structure of database.
▰ Set of Integrity Rules:
▻ It ensures the accuracy of data in the database.

45
Types of Data Models

▰ Object-Based Data Models


▰ Record-Based Data Models
▰ Physical Data Models
▻ Object-based data models and record-based data
models are used to describe data at conceptual and
external levels.
▻ The physical data models are used to describe data
at internal level.

46
Logical Data Models

▰ Object-Based Data Models


▻ Semantics Data Models
▻ The Entity Relationship Model
▰ Record-Based Models
▻ The Relational Model
▻ The Hierarchical Model
▻ The Network Model

47
Semantics Data Models

▰ To define conceptual and external level of data


▰ The most important and power-full model is
▰ The Entity-Relationship Model
▰ Introduced by Chen in mid 1970’s
▰ Graphical method

48
Entity Relationship (ER) Model

▰ In this database model, relationships are created by


dividing object of interest into entity and its characteristics
into attributes.
▰ Different entities are related using relationships.
▰ What is Entity?
▻ An entity is a person, place, thing or event for which
data is collected and maintained. For example, a
library system may contain data about different
entities like book and member. A university system
may include entities like student, teacher and class,
courses.
49
Entity Relationship (ER) Model

▰ Some examples of entities are as follows:


▻ Person: Teacher, Player, Doctor, Student etc.
▻ Place: Country, city
▻ Object: Vehicle, Toy, Furniture
▻ Event: Purchase, admission and registration
▻ Concept: Account, Programming

50
Entity Relationship (ER) Model

▰ E-R Models are defined to represent the relationships into


pictorial form to make it easier for different stakeholders
to understand.
▰ Let's take an example, If we have to design a School
Database, then Student will be an entity with attributes
name, age, address etc.

51
Example 1 - Entity Relationship (ER)
Model: Identify Entities
▰ Case Study
▻ A company has several departments. Each
department has a supervisor and at least one
employee. Employees must be assigned to at least
one, but possibly more departments. At least one
employee is assigned to a project, but an employee
may be on vacation and not assigned to any projects.
▰ Entities:
▻ Company ▻ Employees
▻ Departments ▻ Project
▻ Supervisor
52
Example 2 - Entity Relationship (ER)
Model: Identify Entities

▰ Case study
▻ In a school, a student may be assigned to one or
more posts like perfect, monitor or chairman. A
post must be assigned exactly one student.
▰ Entities:
▻ School
▻ Student
▻ Post

53
Hierarchical Data Model

▰ This database model organizes data into a tree-like-structure,


with a single root, to which all the other data is linked. The
hierarchy starts from the Root data, and expands like a tree,
adding child nodes to the parent nodes.
▰ A child node will only have a single parent node.
▰ Describes many real-world relationships like index of a book,
recipes etc.
▰ Data is organized into tree-like structure with one-to-many
relationship between two different types of data.
▻ for example, one department can have many courses,
many professors and of-course many students.

54
Example 1 - Hierarchical Data
Model

55
Example 2 - Hierarchical Data
Model

56
Network Data Model

▰ Extension of the Hierarchical model.


▰ Data is organized more like a graph, and are allowed to
have more than one parent node.
▰ Data is more related as more relationships are
established in this database model.
▰ Also, as the data is more related, hence accessing the
data is also easier and fast.
▰ This database model was used to map many-to-many
data relationships.
▰ This was the most widely used database model, before
Relational Model was introduced.
57
Example 1 - Network Data
Model

58
Relational Data Model

▰ This model was introduced by E.F Codd in 1970,


and since then it has been the most widely used
database model, in fact, we can say the only
database model used around the world.
▰ The basic structure of data in the relational model is
tables.
▻ All the information related to a particular type is
stored in rows of that table.
▰ Tables are also known as relations in relational
model.

59
Relational Data Model

▰ The database is a set of related relations (table of


values).
▰ Each relation has a name which indicates what type
of tuples the relation has.

▻ For example, a relation named ‘Student’


indicates that it has student entities in it..

60
Relational Data Model

▰ Each relation has a set of attributes (column


names) which represents, what type of information,
the entities or tuples have?
▻ For example, Student relation has a set of
attributes Roll_No., Name, Department.

▰ A tuple / row / record in a relation, is a real-world


entity, it has a set of values for corresponding
attributes.
▻ Each data value in a row or tuple is called field

61
Example - Relational Data
Model

62
Relational Data Model

▰ Cardinality

▻ refers to the number of tuples/rows in a table

▰ Degree

▻ refers to the number of attributes/columns in


a table.

63
JAZAK ALLAH!
Any Question?

You might also like