Databases CIS 422
Lifetime of Data Transient results to the evaluations of expression Variables involved in procedure activation Global variables Dynamically allocated variables Data that exists between executions Data that exits between versions Data that outlives a program
Essentials to Provide Persistence Object ID Properties and relationships Scale of the store Stability of the store
Database vs File System Marketing Engineering Accounting DBMS Database Sales Accounts Employee Inventory Customer Parts Engineering Marketing Accounting Parts Customer Inventory Accounts
Database A collection of related data Represents some aspect of the real world Is a logically coherent collection of data with some inherent meaning Is designed, built, and populated with data for a specific purpose.
Database Management Systems Data Schema Program Independence Views
Hierarchical Model Motor Vehicle BusTruckCar
Network Model Customer Soup Order
Relational Model Soup-ID Soup Name Price Cust-ID Name Address Phone Order-ID Soup-ID Cust-ID Qty
Database Interface Approaches Data Definition Language CREATE TABLE inventory (inventory-number CHAR(20)NOT NULL description CHAR(25)NOT NULL price DECIMAL (9,2) Data Manipulation Language
Shareability Transactions Commit Abort Atomicity
Concurrency Locking Conservative Locking Policy Read Locks Write Locks
Object Oriented vs Traditional Objects are active components OO Databases have inheritance Allow storage in the form of objects
OODBMS - OO Part The system must support complex objects Object identity must be supported Objects must be encapsulated The system must support types or classes The system must support inheritance The system must avoid premature binding The system will be computationally complete The system must be extensible
OODBMS - DB Part It must be persistent, able to remember object state It must be able to manage very large databases It must accept concurrent users It must be able to recover from hardware and software failures Data query must be simple
Complex Objects Job Object OID eee Emp# E001 PositionSalary 50,000 ENAME Smith DEPT# D01 Budget 1,000,000 DNAME Mktg MgrEmpsOID ddd OID sss …... OID’s of Employee Objects
Object Data Management Group Model Parts Literals Objects (OID) –system assigned –not dependent on attribute values –conceptual address Collections
Abstract Types - Interfaces Inherit signatures of operations Noninstantiable Behaviour Inheritance –Supertype must be an interface –Subtype may be interface or class
Classes Specifies both attributes and behavior Instantiable Class Inheritance –supertype must be a class –subtype must be a class
Relationships Inverses 1-1 n-1 n-m
Persistent Objects Naming & Extents Reachablility Key
Company Schema Worker calcDeductions calcPay Employee string name string ssn int dependents Salaried double salary Hourly double hours double rate department n1 office 11
Representation interface Worker { method double calcDeductions(); method double calcpay(); }; class Employee : Worker ( extent workers key ssn) { atttribute string name attribute string ssn attribute int dependents relationship Department worksIn inverse Department::hasEmployees relationship Office residesAt inverse Office::houses }
Representation Continued class Salaried extends Employee ( extent salaried) { attribute double salary } class Department ( extent departments key number) { attribute int number attribute string name relationship set hasEmployees inverse Employee::worksIn }
Table-Class Mapping costcolormakemodelcar Cost color make model
Table-Multiple Classes Mapping nameaddresscustIDempID Employee name address empID Customer name address custID
Table-Inheritance Classes Mapping Employee name ssn address HourlyEmp wage SalariedEmp salary nameaddressssnwagesalary
Instance Relationships NameDepartmentID Name deparmentID ssn salary Department name departmentID Employee name salary ssn
Client Sends message to server Manages user interface –validate data –dispatch requests Solution specific logic GUI
Server Fulfills the client request Usually does database access functions File server Transaction server Located separate from client
Basic Characteristics of Client-Server Apps Front-end client acts with back-end server The two tasks have fundamentally different needs Environment is generally heterogeneous and multivendor Scalability
Common Components User Interface Business Processing Database Processing
Distributed Processing Processing divided up between processes Objects can be distributed and accessed by users across a network