unit 1 DBMS
-
Upload
pratik00100 -
Category
Documents
-
view
246 -
download
0
Transcript of unit 1 DBMS
-
8/3/2019 unit 1 DBMS
1/34
Chapter 1: IntroductionChapter 1: Introduction
-
8/3/2019 unit 1 DBMS
2/34
Data baseData base
The Collection of data, usually referred to as the database, contains informationrelevant to an enterprise.
What is Data base Management System?
DBMS contains information about a particular enterprise
Collection of interrelated data
Set of programs to access the data An environment that is both convenientand efficientto use
-
8/3/2019 unit 1 DBMS
3/34
Database vs. File SystemsDatabase vs. File Systems
-
8/3/2019 unit 1 DBMS
4/34
WhatWhat areare thethe advantagesadvantages andand disadvantagesdisadvantages ofof DatabaseDatabase
ManagementManagement systemsystem overover conventionalconventional filefile system?system?
disadvantages of Database Management system over
conventional file system
Data redundancy and inconsistency
Multiple file formats, duplication of information in different files
Difficulty in accessing data
Need to write a new program to carry out each new task
Data isolation multiple files and formats
Integrity problems
Integrity constraints (e.g. account balance > 0) become buried in programcode rather than being stated explicitly
Hard to add new constraints or change existing ones
-
8/3/2019 unit 1 DBMS
5/34
disadvantagesdisadvantages ofof DatabaseDatabase ManagementManagement systemsystem over over
conventionalconventional filefile systemsystem
Atomicity of updates
Failures may leave database in an inconsistent state with partial updates
carried out
Example: Transfer of funds from one account to another should either
complete or not happen at all
Concurrent access by multiple users
Concurrent accessed needed for performance
Uncontrolled concurrent accesses can lead to inconsistencies
Example: Two people reading a balance and updating it at the same
time
Security problems Hard to provide user access to some, but not all, data
-
8/3/2019 unit 1 DBMS
6/34
advantagesadvantages ofofDatabaseDatabase ManagementManagement systemsystem overover conventionalconventional
filefile systemsystem
A DBMS scores over simple file systems in that it is quicker to access, easier to link
related data items, and much easier to maintain. It also makes more efficient use of
back-up memory resources.
In an office environment, some of the advantages would be improvement of
searching and the implementation of right management.
mainly, you should be aware that a database system, I suppose you're talking about a
relational one, is more per formant, therefore it's quicker to find a record which makesit more cheap than a file System,
-
8/3/2019 unit 1 DBMS
7/34
Levels of AbstractionLevels of Abstraction
Physical 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= record
customer_id:string;
customer_name :string;
customer_street:string;
customer_city:integer;
end;
View level: application programs hide details of data types. Views can also hide
information (such as an employees salary) for security purposes.
-
8/3/2019 unit 1 DBMS
8/34
View ofDataView ofData
Anarchitectureforadatabasesystem
-
8/3/2019 unit 1 DBMS
9/34
DefinesDBMSschemaatthreelevels:
- Internal schema attheinternallevel todescribedatastoragestructures andaccesspaths.Typicallyusesaphysicaldata model.
- Conceptual schema attheconceptuallevel todescribethestructure andconstraints forthe
whole database.Usesaconceptualoranimplementation datamodel.
- External schema attheexternallevel todescribethevarioususerviews.Usually uses the
samedatamodelastheconceptuallevel orhigh-leveldata model.
-
8/3/2019 unit 1 DBMS
10/34
-
8/3/2019 unit 1 DBMS
11/34
Instances and SchemasInstances and Schemas
Schema the logical structure of the database
Example: The database consists of information about a set of customers and
accounts and the relationship between them)
Analogous to type information of a variable in a program
Conceptual organization of entire database as viewed by the database administrator
Physical schema: database design at the physical level Logical schema: database design at the logical level
Instance the actual content of the database at a particular point in time
Analogous to the value of a variable
Database files themselves are useless without the memory structures and processes
to interact with the database. Oracle defines the term instance as the memorystructure and the background processes used to access data from a database.
-
8/3/2019 unit 1 DBMS
12/34
Schema diagram forSchema diagram forUNIVERSITYUNIVERSITY databasedatabase
schemaconstruct
-
8/3/2019 unit 1 DBMS
13/34
UNIVERSITY DatabaseUNIVERSITY Database
-
8/3/2019 unit 1 DBMS
14/34
Sub SchemaSub Schema
That part of a database definition, to be viewed by particular applications, that
describes all or a subset of the data elements, record types, set types, and areas
defined in the schema. It is basically a portion of a schema - usually to show a
particular user department's portion of the database. It identifies a subset of areas,
sets, records, and data names defined in the database schema available to user
sessions.
Defines database portion "seen" by the application programs that actually producethe desired information from data contained within the database
The following are a few of the many reasons sub schemas are used:
Subschemasprovidedifferentviewsofthedatatotheuserandthe
programmer,whodonotneedtoknowallthedatacontainedintheentire
database.
Subschemasenhancesecurityfactorsandprohibitdatacompromise.
-
8/3/2019 unit 1 DBMS
15/34
Data Independence: It is the ability to modify a schema definition in one level withoutaffecting a schema definition in the next higher level. The interfaces between thevarious levels and components should be well defined so that changes in some partsdo not seriously influence others.
Allows data fields to be added, changed, and deleted from a database withoutnecessarily affecting existing application programs.
Two levels of data independence:
Physical data independence
Logical data independence
Physical data independence is the ability to modify the physical schema withoutmaking it necessary to rewrite application programs. E.G., changing from unblocked
to blocked record storage, or from sequential to random-access files. Logical data independence is the ability to modify the conceptual schema without
making it necessary to rewrite application programs. E.G., adding a new field to arecord. An application program's view hides this change from the program.
Data IndependenceData Independence
-
8/3/2019 unit 1 DBMS
16/34
UN
IVERS
ITYConceptual
SchemaSTUDENT(Name,Student Number,Class,Major)
COURSE(Course Name,Course Number,Credit,Dept)
PREREQUISITE(Course Number,Prerequisite Number)
SECTION (SectionId,Course Number,Semester,Year,Instructor)
GRADE_REPORT(Student Number,SectionId,Grade)
UNIVERSITYExternalSchema
TRANSCRIPT(Student Name,Course Number,Grade,Semester,Year,SectionId) derivedfrom
STUDENT,SECTION,GRADE_REPORT
PREREQUISITES(CourseName,Course Number,Prerequisites)
derivedfrom PREREQUISITE,COURSE
-
8/3/2019 unit 1 DBMS
17/34
Data ModelsData Models
Data Model: A set of concepts to describe the structure of a database, and
certain constraints that the database should obey.
A collection of tools for describing
Data
Data relationships
Data semantics
Data constraints
Relational model-Data model based on tables
The relational model uses a collection of tables to represent both data and the
relationships among those data.
Entity-Relationship data model (mainly for database design) The entity relationship (E-R) data model is based on a perception of a real
world that consists of a collection of basic objects, called entities and of
relationship among these objects.
Object-based data models (Object-oriented and Object-relational)-data model
based on the object-oriented programming paradigm
The Object-Oriented data model is another data model that has seen
-
8/3/2019 unit 1 DBMS
18/34
Data ModelsData Models
Semi structured data model (XML) The Semi structured data model permits the
specification of data where individual data items of the same type may have different
sets of attributes.
Other older models:
Network model-data model based on graphs with records as nodes and
relationships between records as edges
Hierarchical model-Data model based on trees
-
8/3/2019 unit 1 DBMS
19/34
Relational ModelRelational Model
Exampleoftabulardataintherelationalmodel
Attributes
-
8/3/2019 unit 1 DBMS
20/34
A Sample Relational DatabaseA Sample Relational Database
-
8/3/2019 unit 1 DBMS
21/34
The EntityThe Entity--Relationship ModelRelationship Model
Modelsanenterpriseasacollectionofentities andrelationships
Entity:athingorobjectintheenterprisethatisdistinguishablefromother
objects
Describedbyasetofattributes
Relationship:anassociationamongseveralentities
Representeddiagrammatically
byanentity-relations
hip diagram:
-
8/3/2019 unit 1 DBMS
22/34
ObjectObject--Relational Data ModelsRelational Data Models
Extend the relational data model by including object orientation and constructs to deal
with added data types.
Allow attributes of tuples to have complex types, including non-atomic values such as
nested relations.
Preserve relational foundations, in particular the declarative access to data, while
extending modeling power.
Provide upward compatibility with existing relational languages.
-
8/3/2019 unit 1 DBMS
23/34
Semi Structured Data ModelsSemi Structured Data Models
Semistructureddatamodelspermitthespecificationofdatawhereindividualdata
itemsofthesametypemayhavedifferentsetsofattributes.Thisisincontrastwith
thedatamodelsmentionedearlier. Whereeverydataitemofaparticulartypemust
havethesamesetofattributes.
XML: Extensible Markup Language
Definedbythe WWW Consortium(W3C)
Originallyintendedasadocumentmarkuplanguagenotadatabaselanguage
Theabilitytospecifynewtags,andtocreatenestedtagstructuresmadeXMLagreat
waytoexchangedata,notjustdocuments
XMLhasbecomethebasisforallnewgenerationdatainterchangeformats.
Awidevarietyoftoolsisavailableforparsing,browsingandqueryingXML
documents/data
-
8/3/2019 unit 1 DBMS
24/34
Data Manipulation Language (DML)Data Manipulation Language (DML)
Languageforaccessingandmanipulatingthedataorganizedbytheappropriatedata
model
DMLalsoknownasquerylanguage
TwotypesofDML
Procedural userspecifieswhatdataisrequiredandhowtogetthosedata
Alsocalledrecord-at-a-time(record-oriented) orlow-levelDML Mustbeembeddedinaprogramminglanguage.
Searchesforandretrievesindividualdatabaserecordsanduseslooping
andotherconstructsofthehostprogramminglanguagetoretrieve
multiple records.
-
8/3/2019 unit 1 DBMS
25/34
Declarative (nonprocedural) userspecifieswhatdataisrequiredwithout
specifyinghowtogetthosedata
Alsocalledset-at-a-time(set-oriented) orhigh-levelDML.
Canbeusedasastand-alonequerylanguageorcanbeembeddedina
programminglanguage.
Searchesforandretrievesinformationfrommultiplerelateddatabaserecordsin
asinglecommand.
Hostlanguage:general-purposelanguage
Datasublanguage:DML
C++
SQL
is
the
most
widely
used
query
language
-
8/3/2019 unit 1 DBMS
26/34
Data Definition Language (DDL)Data Definition Language (DDL)
Specificationnotationfordefiningthedatabaseschema
Example: create table account(
account-number char(10),
balance integer)
DDLcompilergeneratesasetoftablesstoredinadata dictionary
Datadictionarycontainsmetadata(i.e.,dataaboutdata)
Databaseschema
Datastorage and definition language
Specifiesthestoragestructureandaccessmethodsused
Integrityconstraints
Domainconstraints Referentialintegrity(references constraintinSQL)
Assertions Anassertionisanyconditionthatthedatabasemustalways
satisfy.Domainconstraintandreferentialintegrityconstraintarespecial
formsofassertions.
Authorization
-
8/3/2019 unit 1 DBMS
27/34
Database DesignDatabase Design
The process of designing the general structure of the database:
Logical Design Deciding on the database schema. Database design requires that we
find a good collection of relation schemas.
Business decision What attributes should we record in the database?
ComputerS
cience decision W
hat relation schemas should we have and howshould the attributes be distributed among the various relation schemas?
Physical Design Deciding on the physical layout of the database
-
8/3/2019 unit 1 DBMS
28/34
Query ProcessingQuery Processing
1. Parsingand
translation
2. Optimization
3. Evaluation
-
8/3/2019 unit 1 DBMS
29/34
Query Processing (Cont.)Query Processing (Cont.)
Alternative ways of evaluating a given query
Equivalent expressions
Different algorithms for each operation
Cost difference between a good and a bad way of evaluating a query can be enormous
Need to estimate the cost of operations
Depends critically on statistical information about relations which the database mustmaintain
Need to estimate statistics for intermediate results to compute cost of complex
expressions
-
8/3/2019 unit 1 DBMS
30/34
Database ArchitectureDatabase Architecture
The architecture of a database systems is greatly influenced by the underlyingcomputer system on which the database is running:
Centralized
Client-server
Parallel (multi-processor)
Distributed
-
8/3/2019 unit 1 DBMS
31/34
Overall System StructureOverall System Structure
-
8/3/2019 unit 1 DBMS
32/34
Two Tier and Three Tier ArchitectureTwo Tier and Three Tier Architecture
-
8/3/2019 unit 1 DBMS
33/34
Database AdministratorDatabase Administrator
Coordinates all the activities of the database system; the database
administrator has a good understanding of the enterprises information
resources and needs.
Database administrator's duties include:
Schema definition
Storage structure and access method definition
Schema and physical organization modification
Granting user authority to access the database
Specifying integrity constraints
Acting as liaison with users
Monitoring performance and responding to changes in requirements
-
8/3/2019 unit 1 DBMS
34/34
GTU-MCA
http://gtu-mca.blogspot.com