23
DATABASE MANAGEMENT DATABASE MANAGEMENT SYSTEM SYSTEM

DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

Embed Size (px)

Citation preview

Page 1: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

DATABASE MANAGEMENT DATABASE MANAGEMENT SYSTEMSYSTEM

Page 2: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

INTODUCTIONINTODUCTION

Data – fact that can be recorded and that have Data – fact that can be recorded and that have implicit meaning.implicit meaning.

Database – collection of related data.Database – collection of related data. Database management system (DBMS) – Database management system (DBMS) – Collection of interrelated dataCollection of interrelated data Set of programs to access the data Set of programs to access the data An environment that is both An environment that is both convenientconvenient and and

efficientefficient to use to use Exerts centralized control of database, prevents Exerts centralized control of database, prevents

fraudulent or unauthorized users from accessing fraudulent or unauthorized users from accessing the data and ensures privacy of data.the data and ensures privacy of data.

Page 3: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

DATABASE APPLICATIONSDATABASE APPLICATIONS

Banking: all transactionsBanking: all transactions Airlines: reservations, schedulesAirlines: reservations, schedules Universities: registration, gradesUniversities: registration, grades Sales: customers, products, purchasesSales: customers, products, purchases Online retailers: order tracking, customized Online retailers: order tracking, customized

recommendationsrecommendations Manufacturing: production, inventory, orders, Manufacturing: production, inventory, orders,

supply chainsupply chain Human resources: employee records, salaries, Human resources: employee records, salaries,

tax deductionstax deductions

Page 4: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

PURPOSE OF DATABASE PURPOSE OF DATABASE SYSTEMSYSTEM In the early days, database applications were built directly In the early days, database applications were built directly

on top of file systemson top of file systems Drawbacks of using file systems to store data:Drawbacks of using file systems to store data:

Data redundancy and inconsistencyData redundancy and inconsistency Different programmers create files over long period. hence , Different programmers create files over long period. hence ,

Multiple file formats and these leads to duplication of information in Multiple file formats and these leads to duplication of information in different files.different files.

It may lead to data inconsistency since various copies of the same It may lead to data inconsistency since various copies of the same data may no longer agreedata may no longer agree

Difficulty in accessing data Difficulty in accessing data Need to write a new program to carry out each new taskNeed to write a new program to carry out each new task Conventional file system do not allow needed data to be retrieved Conventional file system do not allow needed data to be retrieved

in a convenient and efficient manner. in a convenient and efficient manner.

Data isolation — data are scattered in various files and files Data isolation — data are scattered in various files and files may be in different formats , writing new application programs may be in different formats , writing new application programs to retrieve the appropriate data is difficult.to retrieve the appropriate data is difficult.

Page 5: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

Integrity problemsIntegrity problems Integrity constraints (e.g. account balance > 0) become Integrity constraints (e.g. account balance > 0) become

“buried” in program code by developers rather than being “buried” in program code by developers rather than being stated explicitly.stated explicitly.

Hard to add new constraints or change existing onesHard to add new constraints or change existing ones Atomicity of updatesAtomicity of updates

Failures may leave database in an inconsistent state with Failures may leave database in an inconsistent state with partial updates carried outpartial updates carried out

Example: Transfer of funds from one account to another Example: Transfer of funds from one account to another should either complete or not happen at allshould either complete or not happen at all

Concurrent access by multiple usersConcurrent access by multiple users Concurrent accessed needed for performance ( multiple Concurrent accessed needed for performance ( multiple

users to update data simultaneously )users to update data simultaneously ) Uncontrolled concurrent accesses can lead to Uncontrolled concurrent accesses can lead to

inconsistenciesinconsistencies Example: Two people reading a balance and updating it at the Example: Two people reading a balance and updating it at the

same timesame time Security problemsSecurity problems

Hard to provide user access to some, but not all, dataHard to provide user access to some, but not all, data Database systems offer solutions to all the above Database systems offer solutions to all the above

problemsproblems

Page 6: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

CHARACTERISTICS OF DATABASE APPROACHCHARACTERISTICS OF DATABASE APPROACH In a db approach, a single repository of In a db approach, a single repository of

data is maintained that is defined once data is maintained that is defined once and then accessed by various users.and then accessed by various users.

Characteristic :-DB Vs file approachCharacteristic :-DB Vs file approach a) self describing nature of a database :- a) self describing nature of a database :-

DB system contains database and complete DB system contains database and complete definition db structure and constraints.definition db structure and constraints.

Definition is stored in Definition is stored in database catalog ( database catalog ( containscontains structure of each file, typestructure of each file, type , storage format of each , storage format of each data item, constraints on the data )data item, constraints on the data )

Information stored in database catalog is called Information stored in database catalog is called meta-datameta-data

In file system, data definition is part of the In file system, data definition is part of the application programs themselves application programs themselves

Page 7: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

b) Insulation between programs and b) Insulation between programs and data, data abstraction :-data, data abstraction :-

Structure of data files is stored in the DBMS Structure of data files is stored in the DBMS catalog separately from access programs. This catalog separately from access programs. This property is called property is called program-data independenceprogram-data independence

User application programs can operate on the User application programs can operate on the data by invoking operations through names data by invoking operations through names and arguments, regardless of how the and arguments, regardless of how the operations are implemented. This property is operations are implemented. This property is called called program-operation independence.program-operation independence.

Data abstractionData abstraction – characteristic that allows – characteristic that allows program-data independence and program-program-data independence and program-operation independence. operation independence.

Page 8: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

c) support of multiple views of the data:-c) support of multiple views of the data:- DB has many users, each may require different DB has many users, each may require different

perspective or view of database.perspective or view of database. A view may be subset of the db or contain virtual A view may be subset of the db or contain virtual

data that is derived from the database files but not data that is derived from the database files but not explicitly stored. explicitly stored.

Eg- user 1 require fees details from student dbEg- user 1 require fees details from student db user 2 require course details.user 2 require course details.

d) Sharing of data and multiuser transaction d) Sharing of data and multiuser transaction processing:-processing:-

Multiuser DBMS must allow multiple users to access Multiuser DBMS must allow multiple users to access the db at the same time. So, DBMS must include the db at the same time. So, DBMS must include concurrency control.concurrency control.

Transaction properties :-Transaction properties :- a) Isolation ( Each transaction appears to execute in a) Isolation ( Each transaction appears to execute in

isolation from other transaction )isolation from other transaction ) b) Atomicity ( either all the db operations in a b) Atomicity ( either all the db operations in a

transaction are executed or none are )transaction are executed or none are )

Page 9: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

ADVANTAGES OF USING ADVANTAGES OF USING DBMSDBMS Controlling redundancy – centralized control of data by Controlling redundancy – centralized control of data by

DBA ,avoids unnecessary duplication of data and effectively DBA ,avoids unnecessary duplication of data and effectively reduces total amount of data storage required. reduces total amount of data storage required.

Providing storage structure for efficient query processing. Providing storage structure for efficient query processing.

Restricting unauthorized users – DBA ensures that proper access Restricting unauthorized users – DBA ensures that proper access procedures are followed, including authentication schemes and procedures are followed, including authentication schemes and additional checks before permitting access to sensitive data.additional checks before permitting access to sensitive data.

Providing concurrencyProviding concurrency

Providing backup and recoveryProviding backup and recovery

Enforcing integrity constraints - Db applications have integrity Enforcing integrity constraints - Db applications have integrity constraints that must hold for the data. DBMS must provide constraints that must hold for the data. DBMS must provide capabilities for defining and enforcing these constraints. Data capabilities for defining and enforcing these constraints. Data integrity means that the data contained in the database is both integrity means that the data contained in the database is both accurate and consistent.accurate and consistent.

Page 10: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

Shared data – A db allows sharing of data under Shared data – A db allows sharing of data under its control by any number of application programs its control by any number of application programs or users.or users.

Ability to associate related data.Ability to associate related data. Improved data administration and controlImproved data administration and control

The disadvantages are as follows: The disadvantages are as follows: --Centralization:That is use of the same program :That is use of the same program at a time by many user sometimes lead to loss of at a time by many user sometimes lead to loss of some data. some data.

High cost of software.High cost of software. Technical expertise are required Technical expertise are required security issues security issues Complexity of backup and recoveryComplexity of backup and recovery

Page 11: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

DATA ABSTRACTIONDATA ABSTRACTION Db provide users with an abstract view of the data i.e system hides Db provide users with an abstract view of the data i.e system hides

the complexity from user ( how data are stored and maintained) the complexity from user ( how data are stored and maintained) through several levels of abstraction . These are:- through several levels of abstraction . These are:-

1) Physical level:1) Physical level: describes how a record (e.g., customer) is stored. describes how a record (e.g., customer) is stored. It is the lowest level.It is the lowest level.

2) Logical level:2) Logical level: It is the next higher level. Describes data stored in It is the next higher level. Describes data stored in database, and the relationships among those data. It describes database, and the relationships among those data. It describes entire db. entire db.

typetype customercustomer = = recordrecordcustomer_idcustomer_id : string; : string; customer_namecustomer_name : string; : string;customercustomer__streetstreet : string; : string;customer_citycustomer_city : string; : string;

endend;;

3) View level:3) View level: Highest level . Application programs hide details of Highest level . Application programs hide details of data types. Views can also hide information (such as an employee’s data types. Views can also hide information (such as an employee’s salary) for security purposes. View level simplifies user interaction salary) for security purposes. View level simplifies user interaction with the system. The system may provide many views for the same with the system. The system may provide many views for the same db.db.

Page 12: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

fig.Fig – 3 levels of data abstraction

Page 13: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

INSTANCES AND SCHEMASINSTANCES AND SCHEMAS Similar to types and variables in programming languagesSimilar to types and variables in programming languages

SchemaSchema – the logical structure/design/description of the database – the logical structure/design/description of the database Example: The database consists of information about a set of Example: The database consists of information about a set of

customers and accounts and the relationship between them)customers and accounts and the relationship between them) Analogous to type information of a variable in a programAnalogous to type information of a variable in a program Physical schemaPhysical schema: database design at the physical level: database design at the physical level Logical schemaLogical schema: database design at the logical level: database design at the logical level A db may also have several schemas at view level A db may also have several schemas at view level

InstanceInstance – the actual content of the database at a particular point – the actual content of the database at a particular point in time in time

Analogous to the value of a variable ( WHEN DECLARED )Analogous to the value of a variable ( WHEN DECLARED )

Physical Data IndependencePhysical Data Independence – the ability to modify the physical – the ability to modify the physical schema without changing the logical schemaschema without changing the logical schema

Applications depend on the logical schemaApplications depend on the logical schema In general, the interfaces between the various levels and components In general, the interfaces between the various levels and components

should be well defined so that changes in some parts do not seriously should be well defined so that changes in some parts do not seriously influence others.influence others.

Page 14: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

DATA MODELSDATA MODELS A collection of tools for describing - A collection of tools for describing -

Data , Data relationships , Data semanticsData , Data relationships , Data semantics , Data consistency constraints., Data consistency constraints.

Data model – used to represent entities Data model – used to represent entities and their relationships in the db.and their relationships in the db.

Data model classification:- Data model classification:- a) File based systems or primitive models:- E-R a) File based systems or primitive models:- E-R

modelmodel

b) Traditional data models :-hierarchical , network , b) Traditional data models :-hierarchical , network ,

relational relational

Page 15: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

A) ENTITY RELATIONSHIP MODEL A) ENTITY RELATIONSHIP MODEL Based on the perception of a real world objects called Based on the perception of a real world objects called

entities and relationships among them.entities and relationships among them. Entities can have following type of relationship:-Entities can have following type of relationship:- a) one-to-onea) one-to-one b) one-to-manyb) one-to-many c) many-to-manyc) many-to-many

B) RELATIONAL DATA MODELB) RELATIONAL DATA MODEL Proposed in 1970 by E.F CoddProposed in 1970 by E.F Codd DB2 , oracle , SQL server, SYBASE , INFORMIXDB2 , oracle , SQL server, SYBASE , INFORMIX Model uses relation (table) to represent data and their Model uses relation (table) to represent data and their

relationship. Each table have rows (tuple), columns ( as relationship. Each table have rows (tuple), columns ( as it’s attributes ) and its attribute value (domain)it’s attributes ) and its attribute value (domain)

Record based model Record based model

Page 16: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

C) NETWORK DATA MODELC) NETWORK DATA MODEL Formalized in late 1960s by Database Task Group of the Formalized in late 1960s by Database Task Group of the

conference on Data System Language ( conference on Data System Language ( DBTG/CODASYL)DBTG/CODASYL)

DBTG model uses two different data structure :- record DBTG model uses two different data structure :- record type ( for entities ) and set type ( for relationship type ( for entities ) and set type ( for relationship among them)among them)

Able to model complex relationshipAble to model complex relationship Relationships as well as navigation through the Relationships as well as navigation through the

database is predefined while creating a database.database is predefined while creating a database. Used in DMS 1100(unisys), image(H.P)Used in DMS 1100(unisys), image(H.P)

D) HIERARCHICAL MODELD) HIERARCHICAL MODEL Implemented by IBM and North American Rockwell Implemented by IBM and North American Rockwell

around 1965.around 1965. Used in system 2k( SAS.)Used in system 2k( SAS.) Data is organized in a hierarchical or ordered tree Data is organized in a hierarchical or ordered tree

structure .structure .

Page 17: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

3- SCHEMA ARCHITECTURE3- SCHEMA ARCHITECTURE Proposed to support db approach Proposed to support db approach

characteristics :-characteristics :-

a) Insulation of programs and data a) Insulation of programs and data ( program-data and program-( program-data and program-operation independence)operation independence)

b) support of multiple user viewsb) support of multiple user views

c) use of catalog to schemac) use of catalog to schema

Page 18: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

External level / user view /view level

Conceptual level/ global view

Internal level

External/conceptual mapping

Conceptual/ Internal mapping

(User 1 view) (User 2 view) (User 3 view)

Page 19: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

Internal levelInternal level has an internal schema, which has an internal schema, which describes physical storage structure and access path describes physical storage structure and access path of the db.of the db.

Conceptual levelConceptual level has an conceptual schema, has an conceptual schema, describes structure of whole database for a describes structure of whole database for a community of users. It hides details of physical community of users. It hides details of physical storage structures and concentrates on describing storage structures and concentrates on describing entities, data types, relationships, user operations entities, data types, relationships, user operations and constraints.and constraints.

External levelExternal level has number of external schemas or has number of external schemas or user views. Each external schema describes the part user views. Each external schema describes the part of the db that a particular user group is interested in of the db that a particular user group is interested in and hides other db from that user group.and hides other db from that user group.

Mapping – process of transforming requests and Mapping – process of transforming requests and results between levels.results between levels.

Page 20: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

DATA INDEPENDENCEDATA INDEPENDENCE Defined as the capacity to change the Defined as the capacity to change the

schema at one level of a db system schema at one level of a db system without having to change at next higher without having to change at next higher level.level.

Two types :-Two types :- a) Logical data independence – the a) Logical data independence – the

capacity to change conceptual schema capacity to change conceptual schema without having to change the external without having to change the external schemas and their application programs.schemas and their application programs.

b) Physical data independence- the b) Physical data independence- the capacity to change the internal schema capacity to change the internal schema without having to change the conceptual without having to change the conceptual schema.schema.

Page 21: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

DATABASE LANGUAGESDATABASE LANGUAGES A) DATA MANIPULATION LANGUAGEA) DATA MANIPULATION LANGUAGE

Language for accessing and manipulating Language for accessing and manipulating the data the data

DML also known as query languageDML also known as query language Two classes of languages Two classes of languages

Procedural Procedural Declarative (nonprocedural) Declarative (nonprocedural)

SQL is the most widely used query SQL is the most widely used query languagelanguage

Access types – retrieval , insertion , Access types – retrieval , insertion , deletion, modificationdeletion, modification

Page 22: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

B) DATA DEFINITION LANGUAGEB) DATA DEFINITION LANGUAGE Specification notation for defining the database schemaSpecification notation for defining the database schema

Example:Example: create tablecreate table accountaccount ( ( account_numberaccount_number charchar(10),(10),

branch_name branch_name charchar(10),(10), balancebalance integerinteger))

DDL compiler generates a set of tables stored in a DDL compiler generates a set of tables stored in a data data dictionarydictionary

Embedded and stand aloneEmbedded and stand alone Data dictionary contains metadata (i.e., data about data)Data dictionary contains metadata (i.e., data about data)

Database schema Database schema Data Data storage and definitionstorage and definition language language

Specifies the storage structure and access methods usedSpecifies the storage structure and access methods used Integrity constraintsIntegrity constraints

Domain constraintsDomain constraints Referential integrity (e.g. Referential integrity (e.g. branch_namebranch_name must correspond to a valid must correspond to a valid

branch in the branch in the branchbranch table) table) AuthorizationAuthorization

Page 23: DATABASE MANAGEMENT SYSTEM. INTODUCTION Data – fact that can be recorded and that have implicit meaning. Data – fact that can be recorded and that have

DATABASE ADMINISTRATORDATABASE ADMINISTRATOR Coordinates all the activities of the Coordinates all the activities of the

database systemdatabase system has a good understanding of the enterprise’s has a good understanding of the enterprise’s

information resources and needs.information resources and needs. Database administrator's duties include:Database administrator's duties include:

Storage structure and access method definitionStorage structure and access method definition Schema and physical organization modificationSchema and physical organization modification Granting users authority to access the Granting users authority to access the

databasedatabase Backing up dataBacking up data Monitoring jobs running on the db and ensures Monitoring jobs running on the db and ensures

that performance is not degraded .that performance is not degraded . Administers 3 levels of db.Administers 3 levels of db.