dbms 123- 2011

45
Database Management Systems Course Incharge:  Prof. M. Yousaf Samdani

Upload: waqas-ali-haider

Post on 05-Apr-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 1/45

Database Management Systems 

Course Incharge:  Prof. M. Yousaf Samdani

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 2/45

Objectives of this Course

At the end of this course, you will be able to understand:

Basic concepts and important terms Importance of Database

Design stages of DBMS

At least one database tool i.e. Ms-Access

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 3/45

REFERENCES

Fundamentals of Database Systems – Remez

Al-Masri, S. B. N., Pearson Education Inc. Database Systems  – Thomas Connolly  – 

Second Edition  – Addison Wesley

Introduction to database systems –

C-J. Date – 7th Edition  – Addison Wesley

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 4/45

Objectives of Today’s Lecture 

You will be able to understand the definition

of Data, Data file and Database Applications of Databases in the Real-world

scenarios

Why we design and use database?

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 5/45

What is Data?

These are the raw facts of anything that can berecorded and stored. It may be about livingor non-living objects.

Represented in the form of symbols, words or pictures.

Common Types:1. Numerical e.g. 120, -70, $400, 35.75

2. Character/Strings e.g. Name, Address3. Voice

4. Pictures and graphs

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 6/45

What is a data File?

A collection of related data items stored in one

place against a suitable but valid name.

For example:Personal Data related to students of BBA class (Semester – I)

i.e.Name: -------

Age: --------

Cell #: ------

Address:

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 7/45

Data processing and File Processing

These environments are created for getting

the required information according to thepoint of view of the user.

e.g. Merit list of selected candidates

Some Computer Language/software isrequired to manipulate the data for obtainingthe useful information.

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 8/45

What is a Database ?

Common Definition:

A Database is a shared collection of logically related data that is stored on a media to meet the requirements of different

users of an organization.

Another definition: 

It is a self describing collection of 

integrated records

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 9/45

Why Study Databases??

Shift from  computation to information 

 –  at the “low end”: scramble to webspace (a mess!) 

 –  at the “high end”: scientific applications 

Datasets increasing in diversity and volume.

 –  Digital libraries, Population Data, Banking systems,

interactive video, Human Genome project, EOS project

 – ... need for DBMS exploding

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 10/45

Real-world Applications

1. Commercial Applications e.g. Accounting, Bankingsystems, reservation systems

2. Engineering Systems

3. Social sciences

4. Medical sciences

5. Educational Systems6. Linguistics

7. Word Processing ( Dictionary)

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 11/45

Data Models

A data model   is a collection of concepts for describing data.Or An integrated collection of concepts for describing:

 –    data

 –  relationships between data

 –  constraints on the data in an organization 

A schema  is a description of a particular collection of data, using thea given data model.

The relational model of data  is the most widely used model today. –  Main concept: relation, basically a table with rows and columns.

 –  Every relation has a schema, which describes the columns, or fields.

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 12/45

What is database management system?

A software system that enables users to

define, create, and maintain the databaseand that provides controlled access to the

database.

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 13/45

What is a Data Model?

A data model   is a collection of concepts for

describing data.Or An integrated collection of concepts for

describing:

 –    data –  relationships between data

 –  constraints on the data in an organization 

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 14/45

Record-Based Data Models

Three principal types of record-based logical

data models:

Relational data model

Network data model

Hierarchical data model

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 15/45

Evolution of Database Technologies

Diagram

1960’s  1970’s  1980’s  1990’s 2000+

?

Traditional Files

Hierarchical 

Network 

Relational 

Object 

Object-Relational

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 16/45

What is a Schema and Meta-data?

A schema  is a description of a particular

collection of data, using the a given datamodel.

Meta-data : The information stored in thecatalog is called meta-data. It is all about

data that describes properties orcharacteristics of data

The catalog is used by the DBMS software

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 17/45

Schema diagram DIAGRAM

STUDENT

fname lname regdno class address cellno

coursename courseno credithrs deptno

COURSE

PREREQUISITE

Courseno prerequisteno

SECTION

Sction_id courseno semester year instructor

GRADE

Regdno section_id grade

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 18/45

Relational Model

The relational model of data  is the most

widely used model today. –  Main concept: relation, basically a table with

rows and columns.

 –  Every relation has a schema, which describes

the columns, or fields.

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 19/45

Advantages of DBMS

The data can be shared

Redundancy can be reduced Data inconsistency can be avoided

Transaction support can be provided

Integrity can be maintained

Security can be enforced

Conflicting requirements can be balanced

Standards can be enforced

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 20/45

Disadvantages of DBMS

Complexity

Size Cost of DBMS

Additional hardware costs

Cost of conversion

Performance

Higher impact of a failure

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 21/45

EXAMPLE: DBMS

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 22/45

Major Components of DBMS 

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 23/45

Major Functions of DBMS 

Data definition

Data Manipulation Optimization and Execution

Data Security and Integrity

Data recovery and concurrency Data Dictionary

Performance

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 24/45

Key terms

If you have mastered this topic, you should be ableto use the following terms correctly in your

assignments and exams:

Instance

Domain

Degree Cardinality

Referential integrity

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 25/45

Basic Key terms

Domain

Set of allowable values for one or more attributes.

Attribute values are (normally) required to be atomic,that is, indivisible

 – E.g. multi-valued attribute values are not atomic

 – E.g. composite attribute values are not atomic

Degree

The number of attributes in a relation.

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 26/45

Continued…

Relation Instance

The current values (relation instance) of a relation are specified

by a table

Cardinality

The number of tuple (s) in a relation.

Relational DatabaseA collection of normalized relations with distinct relation

names.

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 27/45

Instances of ‘Branch’ and ‘Staff’ Relations 

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 28/45

Continued …. 

Superkey or Primary Key

An attribute, or a set of attributes, that uniquely identifies atuple within a relation.

Let K R

K  is a  superkey of  R if values for K are sufficient to identifya unique tuple of each possible relation (R) 

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 29/45

Example of Relational Keys 

:customer-name, customer-street} and {customer-name} are both superkeys of Customer

relation, if no two customers can possibly have the same name.

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 30/45

DBMS Languages

DDL: Data definition language is used by the DBAand by the database designers to define both

schemas (Conceptual and Internal).

DML : Data manipulation language is used when thedatabase schemas are compiled and it is populatedwith data. Typical manipulation s include retrieval,

insertion, deletion, and modifications of the data. SDL : Storage definition language is used to

specify the internal schema.

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 31/45

Relational Data Models

It is based on the concept of mathematicalrelations.

In this model, data and relationships arerepresented as table

Each table (relation) has a number of

columns with unique name.

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 32/45

Relational Data Model

Customer table

Younas 

Ahsan 

Mohsen 

Uzma 

customer-name 

MainM-IM-I

G-II

customer-Zone 

KasurLahoreLahore

Gujranwala

customer-city

customer 

attributes

(or columns)

tuples(or rows)

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 33/45

Database Architecture

Why we need a Standardized Architecture?

Three Level Architecture

At what level we interact with the system?

Different Users ( Naïve user,Designer/Programmer, DBA) interact at

different levelsMain objective: separate the user view from

physical view, Example: DoB

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 34/45

Objectives

1. Separate User View from physical view

2. Different views of the same data3. Consolidated representation

4. Both ways easy change

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 35/45

Have U understood the Key terms?

ANSI-SPARC Architecture

External View Schema

DBMS Languages

Data Definition Language  –DDL

Data Manipulation Language  – DML

Storage Definition Language - SDL

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 36/45

ANSI-SPARC Three-Level Architecture

Three Schema 

OR Three Models

1. External View = Level  – I = Virtual/Calculated Data

2. Conceptual View = Logical View/ Schema Middlelayer = Level - II

3.

Internal / Physical View = Level –

III = BottomLayer (Permanent Structure of the data)

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 37/45

Level – I : External View / User view

At this level, the calculated data is shown inthe way the user view the data. It is notactually stored in the database but is createdwhen needed e.g. Age, Name, Any statisticaldata etc.

DBMS uses the external view to create userInterface for different users which is both thefacility and control / barrier 

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 38/45

Level - I External Level

 –  It is the individual user level

 –  An individual user’s view is an external view

 –  The user can be either an application programmer or an enduser

 –  An external view is the content of the database as seen by

Particular user.

 –  This level describes that part of database that is relevant to a

particular user –  Each external view is defined by an external schema

 –  The external schema is written using the external DDL-DataDefinition Language

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 39/45

Level – II : Logical or Conceptual view

A complete description of the informationcontent of the database i.e. Entire information

of the data and its structure (DBA) In terms of Conceptual Schema, The records

containing all entities, attributes, theirrelationships and constraints on the data.

It is semantically designed with the presentneeds as well as future needs of anorganization

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 40/45

Level – II Continued

Conceptual Level

 –  A representation of the entire information content of the database.

 –  Called community view of the database.

 –  Describes what data is stored in database andrelationships among the data.

 –  Conceptual view is defined by the conceptual schema

 –  Conceptual schema is written using the conceptualDDL.

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 41/45

Level – III : Internal or Physical view

It is concerned about the physicalimplementation of the database.

DBMS chooses and represent the type of dataand its structure

Lays out data on the storage device

with the help of Operating System OR

SDL ( Storage Definition Language).

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 42/45

Level – III Continued

Internal Level

It is the low-level representation of the entiredatabase.

Describes how the data is stored in the database.

Physical representation of the database on thecomputer.

The internal view is described by the internal schema

The internal schema is written using the internal DDLor SDL.

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 43/45

Example: University Database

Conceptual schema: –  Students( sid: string, name: string, login: string,

age: integer, gpa:real) –  Courses (cid: string, cname:string, credits:integer)

 –  Enrolled( sid:string, cid:string, grade:string)

Physical schema: – Relations stored as unordered files.

 – Index on first column of Students.

External Schema (View): – Course_info(cid:string,enrollment:integer)

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 44/45

DBMS Environments

RDBMS- Relational Database Managementsystem. It is mainly used to store andmanipulate large amount of data accordingto the relational data model.

1. Single User environment

2. Multi-user environment

8/2/2019 DBMS 123- 2011

http://slidepdf.com/reader/full/dbms-123-2011 45/45

Key Terms used in Level -II

Entity: Any person, place, object, event orconcept about which an organization wishesto maintain data in database is called anEntity.

Person → Employee, Student, Patient

Place →