Full Transcript

Chapter 1: Introduction to Database Systems Outline: 1.1 General Definition  Database  Database Management System (DBMS)  Database System 1.2 Database Systems Vs File Systems  The disadvantages of using file systems to store data 1 1.1...

Chapter 1: Introduction to Database Systems Outline: 1.1 General Definition  Database  Database Management System (DBMS)  Database System 1.2 Database Systems Vs File Systems  The disadvantages of using file systems to store data 1 1.1 General Definitions A Database is:  A collection of related data.  DB examples: Telephone list, Banking System, ….. etc. Database characteristics: 1. It is a logically coherent collection of data. 2. It represents a miniworld, and should represent the state of that world accurately. 3. It is designed for specific purpose. A Database Management System DBMS is: 1. A collection of programs that enables users to defining, constructing and manipulating a databases for various applications. 2. A general purpose software system. 3. Some examples of DBMSs are: o Oracle. o Access. o MySQL. o FoxPro.  Database Defining: o Specifying the data types, structures and constraints for the data to be stored in the database. o Using DDL (Data Definition Language).  Database Constructing: o Storing the data itself on some storage medium. o Using DML (Data Manipulation Language).  Database Manipulating: o Retrieve specific data from database, updating the database to reflect changes in the miniworld and generating reports from data. o Using DML (Data Manipulation Language). A Database System consists of:  Database, DBMS and applications. 2 Users Database System Application Programs / Interfaces DBMS Software to access stored data Database Definition Stored Data (Meta Data) Figure 1.1: The architecture of database system 1.2 Database Systems Vs File Systems  In the early days, database applications were built directly on top of file systems.  File based system is a collection of application programs that perform tasks where each program defines and manage it is own data.  Consider part of a saving-bank that needs to maintain information about its customers and its accounts. Suppose that applications, managing data on customers and accounts, directly use the file systems for storing and retrieving data. o According to such approach, the data concerning customers and accounts are stored in records collected in flat files. There is a file for customer records and a file for the account records. o Each file may have different format. o Programs that use these files depend on knowledge about that format. o Example: account information file Customer No#, CustName, CustAge, Email, AccNo, Balance, Type 123, James, 31, [email protected], 101, 1200, 'saving' 912, Sali, 22, [email protected], 102, 5600, 'checking' 123, James, 31, [email protected], 103, 45553, 'checking' ……. o To manipulate the information, the system has a number of application programs:  A program to add new information. 3  A program to find the balance of an account.  A program to debit or credit an account.  ….. and so on. o Any question (access) on the data is a small program. o The new programs are added to the system as the needed arises. Accounts Customers File File Report File File Report Management Programs Management Programs Programs Programs Accounts File Customers File Figure 1.2: A Simple File System The disadvantages of using file systems to store data: 1. Data redundancy and inconsistency o Multiple file formats, duplication of information in different files. o Problems:  Higher storage leads to waste space.  Data inconsistency (the various copies of the same data may no longer agree (multiple formats). For example, John Smith vs Smith J). 2. Data isolation and Difficulty in accessing data o Data scattered in various files, and files may be in different formats, writing new program to retrieve the data is difficult. o Data characteristics are embodied in programs not stored with the data. o Changes in data characteristics requires modifying programs o Changes in file structures require modification of all programs using that file. o For every query (Ex: find the saving accounts) we need to write a program! 3. Data Integrity Problems o The data values stored in the database must satisfy certain type of consistency constraints. o Constraint example: 4  Account.Balance > 0 o The integrity constraints are part of the program code. o Hard to add new constraints or change the existing ones. 4. Atomicity of updates Problems o Transaction is a sequence of database operations that has the atomicity property:  Atomicity means all operations in the sequence are executed, or no operation is executed. (Do all or nothing). o Failures may leave database in an inconsistent state with partial updates carried out. o Example: Transfer of funds from one account to another should either complete or not happen at all. AccountX.Balance=AccountX.Balance-100 AccountY.Balance=AccountY.Balance+100 o Difficult to guarantee the atomicity of the transactions in the file system. Failures Account X Account Y Balance=2000JD Balance=500JD 100JD Figure 1.3: What are the net balances in Account X and Account Y? 5. Concurrent access by multiple users Problem o Concurrent accessed needed for performance. o Uncontrolled concurrent accesses can lead to inconsistencies. o Why concurrent access to data must be managed?  James and Sali withdraw $50 and $100 from a common account James Sali 1. Get Balance 1. Get Balance 2. If Balance > 50JD 2. If Balance > 100JD 3. Balance = Balance – 50JD 3. Balance=Balance– 100JD 4. Update Balance 4. Update Balance  Initial balance is $300. Final balance=? It depends … 5 James Program1: Balance = Balance -50JD Ac103 300JD Sali Program2: Balance = Balance -100JD Figure 1.4: What is the final value of the balance? o Difficult to control the concurrent access in the file system. 6. Security Problems o Protection from unauthorized use. o Hard to provide user access to some, but not all, data. o Difficult to implement database security. Database Systems offer solutions to all the above problems. 6 A Database System Database Personnel Dept. DBMS Employees Customers Sales Inventory Sales Dept. Accounting Dept. A File System Personnel Dept. Accounting Dept. Sales Dept. Employees Customers Sales Inventory Accounts Figure 1.5 Database System VS. File System 7

Use Quizgecko on...
Browser
Browser