cst203-2 database management systems lecture 2. one tier architecture eg: in this scenario, a...

25
Basic Concepts of Databases CST203-2 Database Management Systems Lecture 2

Upload: harvey-burns

Post on 28-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Basic Concepts of DatabasesCST203-2 Database Management Systems

Lecture 2

One Tier ArchitectureEg:

In this scenario, a workgroup database is stored in a shared location on a single machine

Beneficial when we are dealing with data that is relevant to a single user

Client / Server architectureSystem functionality is distributed between

Client moduleServer module

3 tier architectureTo ensure more security and load balancing

for a greater stability

Data modelsA collection of concepts that can be used to

describe the structure of a database

“An integrated collection of concepts for describing data, relationships between data, and constraints on the data.

Database Solutions: A Step-by-step approach to building databases

Include a set of basic operations for specifying retrievals and updates on db

Categories of Data Models

High-level or Conceptual Data models

Low-level or physical data models

Representational or implementation data models

Relational data model Network data model Hierarchical data model

Levels of AbstractionPhysical level describes how a record (e.g.: customer) is stored.

Logical level: describes data stored in database, and the relationships among the data.

type customer = recordname : string;street : string;city : integer;end;

View level: application programs hide details of data types. Views can also hide information (e.g., salary) for security purposes.

Data modeling using Entity Relationship model

Database Schema

The logical structure of the database

Eg: the database consists of information about a set of customers and accounts and the relationship between them

Database Instance

The actual content of the database at a particular point in time

Three Schema Architecture

The external schemaDefines one view of data as seen by a specific set of

applications or end users

The conceptual schemaDefines data from perspective of system designerIndependent of end users and data storage mechanism

The internal schemaDefines how data is organized, stored and manipulated

in the application itselfTotally dependent on particular implementation

Data Independence

Logical Data Independence

Physical Data Independence

Entity

Represents a real world object or conceptEg: an employee, a project

Attribute

Represents some property of interest that further describes an entityEg: employee’s name or salary

Relationship

Represents an association among 2 or more entitiesEg: an employee works on a project

Example of schema in the entity-relationship model

A Sample Relational Database

Data Definition Language (DDL)Specification notation for defining the database schema

E.g. create table account (

account-number char(10), balance integer)

DBMS have a DDL compiler

Data dictionary contains metadata (i.e., data about data)Database schema Data storage and definition language

language in which the storage structure and access methods used by the database system are specified

Usually an extension of the data definition language

Data Manipulation Language (DML)

Language for accessing and manipulating the data organized by the appropriate data model

DML also known as query language

Two classes of languages Procedural – user specifies what data is required and

how to get those data Nonprocedural – user specifies what data is required

without specifying how to get those data

SQL is the most widely used query language

SQLSQL: widely used non-procedural language

E.g. find the name of the customer with customer-id 192-83-7465select customer.customer-namefrom customerwhere customer.customer-id = ‘192-83-7465’

E.g. find the balances of all accounts held by the customer with customer-id 192-83-7465

select account.balancefrom depositor, accountwhere depositor.customer-id = ‘192-83-7465’ and depositor.account-number = account.account-number

Application programs generally access databases through one of Language extensions to allow embedded SQL Application program interface (e.g. ODBC/JDBC) which allow SQL queries

to be sent to a database

Transaction ManagementA transaction is a collection of operations that performs

a single logical function in a database application

Transaction-management component ensures that the database remains in a consistent (correct) state despite system failures (e.g., power failures and operating system crashes) and transaction failures.

Concurrency-control manager controls the interaction among the concurrent transactions, to ensure the consistency of the database.

Example:Consider a possible interleaving

This is OK. But what about this ???????

T1: A=A+100, B=B-100 T2: A=1.06*A, B=1.06*B

T1: A=A+100, B=B-100 T2: A=1.06*A, B=1.06*B

Storage Management

Storage manager is a program module that provides the interface between the low-level data stored in the database and the application programs and queries submitted to the system.

The storage manager is responsible to the following tasks:

Interaction with the file manager Efficient storing, retrieving and updating of data