Date post: | 23-Feb-2017 |
Category: |
Education |
Upload: | protik-roy |
View: | 15 times |
Download: | 0 times |
Ashis Talukder, MIS, DU
Lecture on
DATABASEAshis TalukderLecturer, MISUniversity Of Dhaka
Ashis Talukder, MIS, DU
IntroductionTraditional File ManagementDBMPurpose of Database SystemsView of DataData Models Data Definition Language Data Manipulation LanguageDatabase AdministratorDatabase UsersOverall System Structure
Ashis Talukder, MIS, DU
Database Data may be logically organized into characters, fields, records, files & databases.
Ashis Talukder, MIS, DU
Database OrganizationDatabase Organization
Bit: − Smallest unit of data− binary digit (0,1/ On, Off & Y, N) − Most basic unit of physical storage
Byte: − Group of bits that represents a single
alphabetic, numeric or other symbols− Also called charcter
ORGANIZING DATA IN A TRADITIONAL FILE ENVIRONMENT
Ashis Talukder, MIS, DU
Database OrganizationDatabase Organization
Field: − Next higher level of data− Consists of group of bytes or a complete
number which represent DETUM or FACT− Example: Name, account number, roll,
balance Record:
− Group of interrelated fields− Example: (11, Mina, 82) (roll, name, marks)
ORGANIZING DATA IN A TRADITIONAL FILE ENVIRONMENT
Ashis Talukder, MIS, DU
Database OrganizationDatabase Organization
File/Table: − Group of records of same type − Example: customer table, account table
ORGANIZING DATA IN A TRADITIONAL FILE ENVIRONMENT
Ashis Talukder, MIS, DU
Database OrganizationDatabase Organization
Database: − Integrated ca− Example: customer table, account table
ORGANIZING DATA IN A TRADITIONAL FILE ENVIRONMENT
Ashis Talukder, MIS, DU
The Data Hierarchy
Ashis Talukder, MIS, DU
Data Hierarchy
Ashis Talukder, MIS, DU
Traditional File Processing
Ashis Talukder, MIS, DU
Database Management System (DBMS) Collection of interrelated data Set of programs to access the data DBMS contains information about a particular enterprise Goal of the DBMS is to provides a way to store and retrieve
database information that is both convenient and efficient. Database Applications:
Banking: Customer Information, loans, and all transactions Airlines: reservations, schedules Universities: registration, grades Sales: customers, products, purchases Manufacturing: production, inventory, orders, supply chain Human resources: employee records, salaries, tax deductions
Databases touch all aspects of our lives
Ashis Talukder, MIS, DU
Purpose of Database System In the early days, database applications were built on top of
file systems Drawbacks of using file systems to store data:
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 part of program code
Hard to add new constraints or change existing ones
Ashis Talukder, MIS, DU
Purpose of Database Systems (Cont.) Drawbacks of using file systems (cont.)
Atomicity of updates Failures may leave database in an inconsistent state with
partial updates carried out E.g. 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 E.g. two people reading a balance and updating it at the same time
Security problems Database systems offer solutions to all the above
problems
Ashis Talukder, MIS, DU
Some Commercial Database Management Systems
Microsoft Access FoxPro dBase Oracle – Oracle 8i, Oracle9i, Oracle 10g Microsoft SQL Server IBM DB2/DB2UDB Informix Sybase MySQL Ingress Postgre SQL
Ashis Talukder, MIS, DU
Levels 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
name : 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.
Ashis Talukder, MIS, DU
Data Abstraction
Ashis Talukder, MIS, DU
Instances and Schemas Similar to types and variables in programming languages Schema – the logical structure of the database
e.g., 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 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
Physical Data Independence – the ability to modify the physical schema without changing the logical schema Applications depend on the logical schema In general, the interfaces between the various levels and components
should be well defined so that changes in some parts do not seriously influence others.
Ashis Talukder, MIS, DU
Data Models A collection of tools for describing
data data relationships data semantics data constraints
Entity-Relationship model Relational model Other models:
object-oriented model semi-structured data models Older models: network model and hierarchical model
Ashis Talukder, MIS, DU
Entity-Relationship Model
Ashis Talukder, MIS, DU
Entity Relationship Model (Cont.)
E-R model of real world Entities (objects)
E.g. customers, accounts, bank branch Relationships between entities
E.g. Account A-101 is held by customer Johnson Relationship set depositor associates customers
with accounts Widely used for database design
Database design in E-R model usually converted to design in the relational model (coming up next) which is used for storage and processing
Ashis Talukder, MIS, DU
customer-name
Customer-id customer-street
customer-city
account-number
Johnson
Smith
Johnson
Jones
Smith
192-83-7465
019-28-3746
192-83-7465
321-12-3123
019-28-3746
Alma
North
Alma
Main
North
Palo Alto
Rye
Palo Alto
Harrison
Rye
A-101
A-215
A-201
A-217
A-201
Attributes
Relational Database Model
Ashis Talukder, MIS, DU
A Sample Relational Database
Ashis Talukder, MIS, DU
Database Language A database system provides a
data-definition language to specify the database schema and a data-manipulation language to express database queries and update.
Ashis Talukder, MIS, DU
Data Definition Language (DDL)
Specification notation for defining the database schema E.g.
create table account ( account-number char(10), balance integer)
DDL is also used to specify additional properties of the data. Example : Alter/DROP/TRUNCATE/ comment/ Grant/ Revoke The storage structure and access methods used by the database system by a
set of statements in a special type of DDL called a data storage and definition language
DDL compiler generates a set of tables stored in a data dictionary 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
Ashis Talukder, MIS, DU
DDL ……………. Cont. The data values stored in the database must satisfy certain consistency
constraints. Domain Constraints : A domain of possible values must be associated
with every attribute ( i.e. Char type, integer type, date/time etc) Referential Integrity : There are cases where we wish to ensure that a
value that appear in one relation for a given set of attribute also appears for a certain set of attributes in another relation.
Assertions: An assertion is any condition that the database must always satisfy. i.e Account Balance >=$100
Authorization : differentiate among the user as far as the type of access they are permitted on various data values in the database. Read authorization Insert authorization Update authorization Delete authorization.
Ashis Talukder, MIS, DU
Database Languages The output of the DDL is placed in the data dictionary, which contains
metadata- that is, data about data. 1. relation-metadata (relation-name, no-of-attributes, storage-organization, location)
2. attribute-metadata (attribute-name, relation-name, domain-type, position, length)
3. user-metadata (user-name, encrypted-password, group)
4. index-metadata (index-name, relation-name, index-type, index-attributes)
5. view-metadata (view-name, definition)
Ashis Talukder, MIS, DU
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
Ashis Talukder, MIS, DU
SQL SQL: 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
Ashis Talukder, MIS, DU
An Un-normalized Relation for ORDER
Ashis Talukder, MIS, DU
Normalized Tables Created from ORDER
Ashis Talukder, MIS, DU
Database Users Users are differentiated by the way they expect to
interact with the system. Four different types: 1. Naive users – are unsophisticated users who interact
with the system by invoking one of the permanent application programs that have been written previously.
E.g. people accessing database over the web, bank tellers, clerical staff2. Application programmers – are computer professionals who write application programs. Application programmers can choose from many tools to develop user interface.
Ashis Talukder, MIS, DU
Database Users 3. Sophisticated users – interact with the system without
writing programs. Instead, they form their requests in a database query language. Analysts who submits queries to explore data in the database.e.g., analyst looking at sales data (OLAP – Online analytical processing), data mining – finds certain kinds of patterns in data.
4. Specialized users – are sophisticated users who write specialized database applications that do not fit into the traditional data processing framework.e.g., computer-aided design systems, knowledge-base and expert systems and environment-modeling systems – uses complex data types.
Ashis Talukder, MIS, DU
Database Administrator (DBA) Coordinates all the activities of the database system; the
database administrator has a good understanding of the enterprise’s information resources and needs. DBA has central control of both data and the programs that access that data.
The functions of Database administrator (DBA) include: Schema definition Storage structure and access method definition Schema and physical-organization modification Granting of authorization for data access
Ashis Talukder, MIS, DU
Transaction Management A transaction is a collection of operations
that performs a single logical function in a database application
e.g., deposit, withdrawal, transfer between accounts
A – Atomicity, C – Consistency, I – Isolation, D - Durability
Ashis Talukder, MIS, DU
Transaction Management 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
e.g., system crash cannot wipe out “committed” transactions
Ashis Talukder, MIS, DU
Storage Manager A 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 translates the various DML statements into low-level file system thus
The storage manager is responsible for Efficient storage, retrieval and updating of data in the database.
The storage manager components include : Authorization & Integrity manager: test for satisfaction of integrity
constraints and checks the authority of user to access data. Transaction manager: which ensure that the database remains in a
consistent despite of power failure. File Manager: Which manages the allocation of space on disk storage & the
data structures used to represent information stored on disk. Buffer Manager : Which is responsible for fetching data from disk storage into
main memory, and deciding what data to cache in main memory.
Ashis Talukder, MIS, DU
Storage Manager
The storage manager stores:
Data files (relations): which stores the database itself.
Data dictionary : Which stores metadata about structure of the database, in particular the schema of the database. (sometimes called catalog)
Indices : which can provide fast access to dataItems. Like Index of a text book.
Ashis Talukder, MIS, DU
The Query Processor
Components include:1. DDL interpreter : Which Interprets DDL statements and records the definitions in the dictionary.2. DML compiler : Which translates DML statements in a query language into an evaluation plan consisting of low level instruction that the query evaluation engine understand. 3. Query evaluation engine : Which execute low-level instructions generated by the DML compiler.
Ashis Talukder, MIS, DU
Database Administrator Coordinates all the activities of the database system; the database
administrator has a good understanding of the enterprise’s 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
Ashis Talukder, MIS, DU
Overall System Structure
Ashis Talukder, MIS, DU
Application Architectures
Two-tier architecture: E.g. client programs using ODBC/JDBC to communicate with a databaseThree-tier architecture: E.g. web-based applications, and applications built using “middleware”
Ashis Talukder, MIS, DU
Centralized database:
• Used by single central processor or multiple processors in client/server network
• There are advantages and disadvantages to having all corporate data in one location.
• Security is higher in central environments, risks lower.
• If data demands are highly decentralized, then a decentralized design is less costly, and more flexible.
Distributing DatabasesDistributing Databases
Ashis Talukder, MIS, DU
• Databases can be decentralized either by partitioning or by replicating
• Partitioned database: Database is divided into segments or regions. For example, a customer database can be divided into Eastern customers and Western customers, and two separate databases maintained in the two regions.
CREATING A DATABASE ENVIRONMENT
Distributed database:
Ashis Talukder, MIS, DU
• Duplicated database: The database is completely duplicated at two or more locations. The separate databases are synchronized in off hours on a batch basis.
• Regardless of which method is chosen, data administrators and business managers need to understand how the data in different databases will be coordinated and how business processes might be effected by the decentralization.
CREATING A DATABASE ENVIRONMENT
Ashis Talukder, MIS, DU
• The quality of decision making in a firm is directly related to the quality of data in its databases.
• Data Quality Audit: Structured survey of the accuracy and level of completeness of the data in an information system
• Data Cleansing: Consists of activities for detecting and correcting data in a database or file that are incorrect, incomplete, improperly formatted, or redundant
CREATING A DATABASE ENVIRONMENT Ensuring Data Quality:
Ashis Talukder, MIS, DU
Online Analytical Processing (OLAP):
• Multidimensional data analysis
• Supports manipulation and analysis of large volumes of data from multiple dimensions/perspectives
DATABASE TRENDS
Multidimensional Data AnalysisMultidimensional Data Analysis
Ashis Talukder, MIS, DU
Multidimensional Data Model
DATABASE TRENDS
Ashis Talukder, MIS, DU
Data warehouse: A Data warehouse is a database that stores current & historical data of potential interest to manager throughout the company
• Supports reporting and query tools
• Stores current and historical data
• Consolidates data for management analysis and decision making
DATABASE TRENDS
Data Warehousing and Data Mining Data Warehousing and Data Mining
Ashis Talukder, MIS, DU
Components of a Data WarehouseDATABASE TRENDS
Ashis Talukder, MIS, DU
Data mart: • Subset of data warehouse
• Contains summarized or highly focused portion of data for a specified function or group of users
DATABASE TRENDS
Data mining:
• Tools for analyzing large pools of data
• Find hidden patterns and infer rules to predict trends
Ashis Talukder, MIS, DU
Benefits of Data Warehouses:
• Improved and easy accessibility to information
• Ability to model and remodel the data
DATABASE TRENDS