Www.techstudent.co.cc1 Database Systems. Overall view Unit I – Architecture, introduction to...
-
Upload
sydney-mccoy -
Category
Documents
-
view
213 -
download
0
Transcript of Www.techstudent.co.cc1 Database Systems. Overall view Unit I – Architecture, introduction to...
www.techstudent.co.cc 1
Database Systems
www.techstudent.co.cc 2
Overall view• Unit I
– Architecture, introduction to DBMS,RDBMS and SQL
• Unit II
– Basics of relational model
• Unit III
– Views, FDs and Normal forms (1NF – 3NF, BCNF)
• Unit IV
– 4NF, 5NF, ER diagrams, transactions• Unit V
– Security, Distributed database, Object/Relational DB
www.techstudent.co.cc 3
Definitions
www.techstudent.co.cc 4
Basic Definitions
• Data -raw facts that are recorded( unprocessed)
• Information is derived from data• Example :
– Unprocessed facts(data)• Bill Number : 3425• Bill date : 20-June-2007• Bill amount: Rs. 10000
– Information is processed facts• The bill number 3425 dated 20th june 2007 has
amount of Rs. 10,000.
www.techstudent.co.cc 5
Basic Definitions
• Database– collection of related data
DBMS – A system for defining, creating, manipulating and
querying data – Shelters users from storage format of database
www.techstudent.co.cc 6
Functions of DBMS
• Major Functions– Data Definition– Data construction– Data manipulation
• Other functions– Data recovery– Data security and integrity– Data dictionary etc…
www.techstudent.co.cc 7
To note…..
• Not every database is managed by a DBMS
• A DBMS is general purpose software. i.e, it is not application specific
• A DBMS takes care of storing and accessing data, leaving only application specific tasks to application programs
www.techstudent.co.cc 8
Files Vs Databases
www.techstudent.co.cc 9
Files Vs databases
• Database – a collection of data that is multidimensional– internal links between its entries make the
information accessible from a variety of perspectives
• Flat File – a traditional one-dimensional file storage
system that presents its information from a single point of view
www.techstudent.co.cc 10
www.techstudent.co.cc 11
Conceptual layers of DB management
www.techstudent.co.cc 12
What is a database system?
www.techstudent.co.cc 13
Database Systems
• A software that controls the – Organization– Storage– Retrieval– Security – Integrity of data in a database
www.techstudent.co.cc 14
Database systems
It accepts requests from the application program and instructs the operating system to fetch the desired data
www.techstudent.co.cc 15
Database systems
• A database system is a computerized system whose overall purpose is to store information and to allow users to retrieve and update the information on demand
www.techstudent.co.cc 16
Simplified picture of database systems
database
Application programs End usersDatabase Management System(DBMS)
www.techstudent.co.cc 17
Database systems
• Four major components– Data– Hardware– Software– users
www.techstudent.co.cc 18
Data
• Database systems are available in smaller or larger systems
• Single-user system:– System in which at most one user can
access the database at any given time
• Multi-user system:– System in which many users can access
the database at the same time
www.techstudent.co.cc 19
Data
• Data in the database is both integrated and shared
• Integrated: – database is a unification of several distinct files– The redundancy among the files are partially or wholly
eliminated
• Shared :– Different users can have access to the same data– I.e, database can be shared among different users
www.techstudent.co.cc 20
Hardware
• Hardware components consists of – Secondary storage volumes
• Magnetic disks, I/O devices, device controllers, I/O channels etc.
– Hardware processor and associated main memory that support the execution of the database system software
www.techstudent.co.cc 21
Software
• Between the actually stored data and the users of the system, there is a layer of software called as Database Management System(DBMS). – DBMS is also called as database manager or database
server
• All requests for accessing the database are handled by the DBMS
• Thus the main function of DBMS is to shield the database users from the hardware-level details
www.techstudent.co.cc 22
Software
• Note:– DBMS is the most important software
component in the overall system.• Others software include utilities, application
development tools, design aids, report writers and the transaction manager.
– The term DBMS instance refers to a particular copy of a product that runs at a particular time.
www.techstudent.co.cc 23
Users
• Application Programmers
• End User
• Database Administrator
www.techstudent.co.cc 24
Users-Application Programmers
• Responsible for writing application programs which allow end users to access the database interactively.
• Application can be written in some programming languages like COBOL ,C, C++, Java etc..
• Programs access the database by issuing appropriate requests to the DBMS
www.techstudent.co.cc 25
Users- End Users
• Persons who access database for querying, updating and generating reports
• Categories– Casual End Users– Naïve or parametric users– Sophisticated end users– Stand alone users
www.techstudent.co.cc 26
Users- End Users
• Casual End Users:– Occasional access– Different information each time– Typically middle or high level managers or
occasional browsers
• Naïve or parametric end users– Constant querying and updating database– Use standard queries
www.techstudent.co.cc 27
Users- End Users
• Sophisticated End users– Familiarized with the facilities of DBMS inorder
to meet the complex requirements– Include engineers, scientists, business analysts,
etc.,,
• Stand-alone users– Maintain personal databases by using ready-made
program packages that provide easy-to-use menu or graphics-based interfaces
www.techstudent.co.cc 28
Users- Database administrator
• a person who has the central responsibility of data is data administrator
• Data administrator is a manager.
• The technical person who implements data manager’s decision is Database administrator(DBA)
www.techstudent.co.cc 29
Users- Database administrator
• DBA is responsible for– Creating the actual database– Authorizing access– Coordinating and monitoring the db use– Acquiring hardware and software resources– Ensures that system operates with adequate
performance
www.techstudent.co.cc 30
Why Database?
www.techstudent.co.cc 31
Database Vs paper-based methods
• Compactness
• Speed
• Less drudgery
• Current, up-to-date information
• Protection
www.techstudent.co.cc 32
Benefits of database Approach
• Data can be shared
• Redundancy can be reduced
• Inconsistency can be avoided
• Transaction support can be provided
www.techstudent.co.cc 33
Benefits of database Approach
• Integrity can be maintained
• Security can be enforced
• Conflicting requirements can be balanced
• Standards can be enforced
www.techstudent.co.cc 34
Data independence
• One of the most important benefits of DBMS
• Two types– Physical data independence– Logical data independence
www.techstudent.co.cc 35
Data independence
• Logical data independence– Protection from changes in logical structure of
data
• Physical data independence– Protection from changes in physical structure
of data
www.techstudent.co.cc 36
Types of DBMSs
• Relational – Data model based on tables
• Network – data model based on graphs with records as nodes and relation ship between records as edges
• Hierarchical – data model based on trees
www.techstudent.co.cc 37
Types of DBMSs
• Object-oriented – data model based on object-oriented programming paradigm
• Distributed- composed of several independent DBMSs running at the nodes of a communications network
www.techstudent.co.cc 38
Overhead costs of a DBMS
• High initial investment in hardware, software and training
• Generality for defining and processing data
• Overhead for providing security, concurrence control, recovery and integrity functions
www.techstudent.co.cc 39
When not to use a DBMS
• Can't afford the overhead– Cost of the DBMS– Training time– Processing time
• Application is simple– Single table
www.techstudent.co.cc 40
Database System Architecture
www.techstudent.co.cc 41
Three levels of Architecture
• Internal level (or storage level)– Concerned with the way data is stored inside the
system
• External level (or user logical level)– Concerned with the way data is seen by individual
users
• Conceptual level (or community logical level)
– Level of indirection between the other two
www.techstudent.co.cc 42
Three levels of Architecture
External level
Conceptual Level
Internal Level
www.techstudent.co.cc 43
Three levels of Architecture
• There may be many distinct external views
• There will be precisely one conceptual view
• There will be precisely one internal view representing the data stored internally
• External and conceptual are both model levels
• Internal level is an implementation level
www.techstudent.co.cc 44
Three levels of Architecture- Example
External (C)Struct employee{ char empno(6); int salary;
}
External (COBOL)01 EMPC. 02 EMPNO PIC X(6). 02 DEPTNO PIC X(4).
ConceptualEMPLOYEE EMPLOYEE_NUMBER CHARACTER(6) DEPARTMENT_NUMBER CHARACTER(4) SALARY DECIMAL(5)
InternalSTORED_EMPLOYEE BYTES=20
PREFIX BYTES=6, OFFSET=0EMP# BYTES=6, OFFSET=6, INDEX=EMPXDEPT# BYTES=4.OFFSET=12PAY BYTES=4,ALIGN=FULLWORD,OFFSET=16
www.techstudent.co.cc 45
External Level
• Individual user level• User can be application programmer or end
user• Each user has a language
– Application programmer may use a conventional programming language or a language specific to the system
– End user may use a query language or some special-purpose language.
www.techstudent.co.cc 46
External level
• All languages will include a data sublanguage
• Data Sublanguage is said to be embedded within the host language
• A data sublanguage supported by all current systems is SQL
• SQL can be used interactively as stand-alone query language and also embedded in other languages
www.techstudent.co.cc 47
External Level
• If the data sublanguage and the host language are not distinct, it is said to be tightly coupled
• If they are clearly and easily separable , it is loosely coupled.
• Any data sublanguage has two subordinate languages– Data Definition Language (DDL)– Data Manipulation Language (DML)
www.techstudent.co.cc 48
External Level
• ANSI SPARC term for individual user’s view is an external view
• External view consists of many occurrences of many types of external record
• Each external view is defined by an external schema
• External schema is written using the DDL portion of the user’s data sublanguage
www.techstudent.co.cc 49
Conceptual Level
• Conceptual view is a representation of entire information in a form somewhat similar to the physical storage.
• Consists of many occurrences of many types of conceptual record
• Conceptual view is defined by a conceptual schema
www.techstudent.co.cc 50
Conceptual Level
• Conceptual schema is written using conceptual DDL
• To achieve physical data independence, the DDL definitions should not involve any physical representation or access technique at all.
www.techstudent.co.cc 51
Internal Level
• Internal view is the lowest level of representing the database
• Consists of several occurences of many types of internal record
• Internal record is the ANSI/SPARC term for the construct stored record
• Internal view is described by an internal schema.
www.techstudent.co.cc 52
Internal Level
• Internal schema– Specifies what indexes exist– How stored fields are represented– The physical sequence of the stored records ,
etc.,
www.techstudent.co.cc 53
Mappings
• Conceptual/ internal mapping- key for providing physical data independence
• External /conceptual mapping– Key for providing logical data independence
• External/ external mapping
www.techstudent.co.cc 54
Database Administrator-Tasks
• Defining Conceptual Schema– DA identifies the entities of interest and information
to be recorded about those entities.This process is called logical database design
– DBA creates the corresponding conceptual schema using the conceptual DDL
– The compiled form of that schema will be used by DBMS to respond to user requests
– Uncompiled form will be the reference document for the users of the system
www.techstudent.co.cc 55
Database Administrator-Tasks
• Defining the internal Schema– DBA decides how data is to be represented in the
stored database. This is called as physical database design
– DBA also creates the corresponding stored data definition(internal schema) and the associated conceptual/internal mapping
www.techstudent.co.cc 56
Database Administrator-Tasks
• Liaising with users– DBA communicates with the users to ensure
that data they need is available– Help users write the external schemas– Provide the conceptual/external mapping– Provide technical help– Assist with problem determination and
resolution
www.techstudent.co.cc 57
Database Administrator-Tasks• Define security and integrity constraints
– Conceptual DDL must include facilities for specifying security and integrity constraints
• Monitoring performance and responding to changing requirements– DBA is responsible for organising the system to
get the best performance by• Making appropriate changes when requirement
changes(tuning)• Reorganize the stored data so that performance level
remains acceptable
www.techstudent.co.cc 58
Database Administrator-Tasks
• Defining Dump/ restore schemes– Data errors should be repaired with minimum
delay and with little effect on the rest of the system– DBA should design and implement an appropriate
damage control scheme involving • Dumping database to backup storage
• Reloading the database from the most recent dump
www.techstudent.co.cc 59
Database Management System
• Software that handles all access to the database – User issues an access request using DSL– DBMS accepts the request and analyzes it– DBMS in turn inspects the external schema for that
user, corresponding external/conceptual mapping, conceptual schema, conceptual/internal mapping and stored database definition
– DBMS executes the necessary operations on the stored database
www.techstudent.co.cc 60
Functions of DBMS
• Data definition– DBMS must be able to accept data definitions in
source form and convert them to the appropriate object form
– i.e DBMS must include DDL processor or DDL compiler components for each DDL
– It should understand the DDL definitions and be able to use this knowledge to respond to data manipulation requests
www.techstudent.co.cc 61
Functions of DBMS
• Data manipulation– DBMS must include a DML processor or a DML
compiler to deal with DML. That is, it should be able to handle requests to retrieve,update or delete data in database or add new data
– DML requests can be planned or unplanned• Planned: need is known in advance of request
• Unplanned: need not known in advance but arose all of a sudden
www.techstudent.co.cc 62
Functions of DBMS
• Optimization and execution– Determines an efficient way of implementing the
request– Planned or unplanned DML requests must be
processed by optimizer component– Optimized requests are then executed under the
control of run-time manager
www.techstudent.co.cc 63
Functions of DBMS
• Data security and integrity– The DBMS should monitor user requests and
reject any requests that violate the security and integrity constraints
– These tasks can be performed in compile time or run-time or mixture of two
• Data recovery and concurrency– DBMS or the transaction manager must enforce
recovery and concurrency controls
www.techstudent.co.cc 64
Functions of DBMS
• Data dictionary– Contains data about data (called metadata)– Contains all schemas and mappings and all
security and integrity constraints both in source and object form
• Performance– Should perform all its tasks as efficiently as
possible
www.techstudent.co.cc 65
Client/Server Architecture
• Database system is considered as a two-part-structure– Server (or back end)
• Server is the DBMS itself
• Supports all DBMS activities
– Clients (or front ends)• Various applications that run on DBMS
• Server makes no difference between user-written applications and vendor-provided applications
www.techstudent.co.cc 66
Client/Server Architecture
• User-written applications– Regular application programs written in 3GL or
4GL– In both cases the language should be combined
with DSL
• Vendor-provided applications– Applications which assist in creation and execution
of other applications
www.techstudent.co.cc 67
Client/Server Architecture
• Vendor-provided tools– Query language processor– Report writers– Business graphics subsystem– Spreadsheet– Natural language processor– Statistical packages– Application generators– Data mining and visualisation tools
www.techstudent.co.cc 68
Distributed processing
• Distinct machines can be connected into some kind of communications network such that a single data processing task can be spread across several machines in the network
• Communication among the machines is handled handled by some network management software
www.techstudent.co.cc 69
Distributed processing• (I)Simple case:Running DBMS back end on
one machine and application front end on another machine
Applications
DBMS
Client machine
Transparent remote access
Server machine
www.techstudent.co.cc 70
Distributed processing
• Arguments in favor:– Response time and throughput is improved as the server
and client processing are done in parallel.
– Since server machine is a custom-built machine tailored to DBMS function it could provide better performance
– Similarly client machine is designed to meet the end user’s requirement and thus be able to provide high availability, faster responses and overall improved ease of use.
– Several different client machines may be able to access the same server. Thus, a single database may be shared across several distinct clients
www.techstudent.co.cc 71
Distributed processing
Communication network
Server machine
Client
machines
a single database may be shared across several distinct clients
www.techstudent.co.cc 72
Distributed processing
• Client machine may have stored data of their own and server machines may have applications of its own
• Therefore each machine will act as a server for some users and a client for others. That is, each machine will support an entire database system
www.techstudent.co.cc 73
ClientServer
ClientServer Client
Server
ClientServer
ClientServer
Communication
Network
www.techstudent.co.cc 74
Distributed processing
• Single machine may be able to access several server machines
• This facility can be provided in two different ways– A given client might be able to access any
number of servers, but only one at a time– The client may be able to access many
servers simultaneously. In this method, servers look to the client from a logical point of view as if it a single server
www.techstudent.co.cc 75
Introduction to Relational Databases
www.techstudent.co.cc 76
Catalog
• Stores – the various schemas– Corresponding mapping– Detailed information also called as descriptor
information or metadata• Eg: relvars ,indexes, users, integrity constraints,
security constraints
– The catalog itself contains many relvars. Hence users can interrogate with the data
www.techstudent.co.cc 77
BaseTables and views
• Tables in relational model are called base tables as they have physical existence
• Tables that exist virtually are called views
• View is a virtual table derived from one or more tables
• The command provided by the user to create a view is stored in data dictionary
www.techstudent.co.cc 78
Transactions
• A logical unit of work
• Transaction– begins when BEGIN TRANSACTION
operation is executed– Terminates with COMMIT or ROLLBACK
www.techstudent.co.cc 79
Transactions
• Are atomic– Either executed entirely or not at all
• Guaranteed to be durable– When COMMIT is executed successfully updates are in
database
• Isolated from one another– Transaction T1 is not visible to T2 until T1 is committed
• Serializable– Set of transactions produce the same result as executing
them one by one