67
IS 257 – Spring 2004 2004.03.18- SLIDE 1 Data Administration and Database Administration University of California, Berkeley School of Information Management and Systems SIMS 257: Database Management

Data Administration and Database Administration

  • Upload
    macha

  • View
    74

  • Download
    1

Embed Size (px)

DESCRIPTION

Data Administration and Database Administration. University of California, Berkeley School of Information Management and Systems SIMS 257: Database Management. Final Project Requirements Review Fourth Generation Languages PHP implementation Object-Relational Extensions to SQL - PowerPoint PPT Presentation

Citation preview

Page 1: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 1

Data Administration and Database Administration

University of California, BerkeleySchool of Information Management

and Systems SIMS 257: Database Management

Page 2: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 2

Lecture Outline• Final Project Requirements• Review

– Fourth Generation Languages– PHP implementation

• Object-Relational Extensions to SQL• Database Administration

Page 3: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 3

Lecture Outline• Final Project Requirements• Review

– Fourth Generation Languages– PHP implementation

• Object-Relational Extensions to SQL• Database Administration

Page 4: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 4

Final Project Requirements• See WWW site:

– http://sims.berkeley.edu/courses/is257/f04/index.html• Report on personal/group database including:

– Database description and purpose– Data Dictionary– Relationships Diagram– Sample queries and results (Web or Access tools)– Sample forms (Web or Access tools)– Sample reports (Web or Access tools)– Application Screens (Web or Access tools)

Page 5: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 5

Lecture Outline• Final Project Requirements• Review

– Fourth Generation Languages– PHP implementation

• Object-Relational Extensions to SQL• Database Administration

Page 6: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 6

Fourth Generation Languages

• 1st Generation -- Machine Language• 2nd Generation -- Assembly Languages• 3rd Generation -- High-Level Languages• 4th Generation -- Non-Procedural

Languages• 5th Generation -- ?? Knowledge-based ??

Natural Language ??• Where do Object-Oriented Languages

fit??

Page 7: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 7

Components of a 4GLApplication Parameters

Testingtools/debugger

Interpreter Optimizingcompiler

RulesSpecification

DataSpecification

ReportSpecification

ScreenSpecification

Proceduralfacility

Feedback

for building routine applications…

Page 8: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 8

Natural Language• Advantages of using NL

– It encourages untrained users to start– It encourages upper-management use of

computers– It reduces the time taken learning complex

syntax – It lessens the frustration, bewilderment and

anger caused by BAD COMMAND responses– It is likely to extend greatly the usage of

computers James Martin, Fourth Generation Languages, 1985

Page 9: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 9

Natural Language• It lacks precision• It is not good for

expressing precise and complex logic

• It is not good for expressing neat structures

• It encourages semantic overshoot

• It should be combined with other dialogue contructs that aid in the representation of precise logic and structures

James Martin, Fourth Generation Languages, 1985

Disadvantages of using NL Appropriate response to the disadvantage

Page 10: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 10

Natural Language• It takes substantial

time to key in sentences

• Ambiguities are possible

• Substantial processing is needed

• Sentences and words can be abbreviated

• Speech input as well as typed input will be used

• The computer should detect and resolve ambiguities

• The processing should be on PC workstations. Processing is dropping rapidly in cost.

James Martin, Fourth Generation Languages, 1985

Disadvantages of using NL Appropriate response to the disadvantage

Page 11: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 11

Assumptions and Issues• Why 4GLs?

– Are they still appropriate?– Are they still useful?

• Is Cold Fusion a 4GL?• What about PHP?• Who needs them?

Page 12: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 12

Diveshop PHP• The same interface (with minor differences)

that we saw for ColdFusion has been implemented in PHP and MySQL

• Address for the example is – http://dream.sims.berkeley.edu/~ray/Diveshop/index.php3

• To setup your own MySQL database you will need to use the “my.sims” interface to request a MySQL account and PHP access

Page 13: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 13

Lecture Outline• Final Project Requirements• Review

– Fourth Generation Languages– PHP implementation

• Object-Relational Extensions to SQL• Database Administration

Page 14: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 14

Object Relational Databases• Background• Object Definitions

– inheritance• User-defined datatypes• User-defined functions

Page 15: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 15

Object Relational Databases• Began with UniSQL/X unified object-

oriented and relational system• Some systems (like OpenODB from HP)

were Object systems built on top of Relational databases.

• Miro/Montage/Illustra built on Postgres.• Informix Buys Illustra. (DataBlades)• Oracle Hires away Informix Programmers.

(Cartridges)

Page 16: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 16

Object Relational Data Model• Class, instance, attribute, method, and

integrity constraints• OID per instance• Encapsulation• Multiple inheritance hierarchy of classes• Class references via OID object

references• Set-Valued attributes• Abstract Data Types

Page 17: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 17

Object Relational Extended SQL (Illustra)

• CREATE TABLE tablename {OF TYPE Typename}|{OF NEW TYPE typename} (attr1 type1, attr2 type2,…,attrn typen) {UNDER parent_table_name};

• CREATE TYPE typename (attribute_name type_desc, attribute2 type2, …, attrn typen);

• CREATE FUNCTION functionname (type_name, type_name) RETURNS type_name AS sql_statement

Page 18: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 18

Object-Relational SQL in ORACLE

• CREATE (OR REPLACE) TYPE typename AS OBJECT (attr_name, attr_type, …);

• CREATE TABLE OF typename;

Page 19: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 19

Example• CREATE TYPE ANIMAL_TY AS OBJECT

(Breed VARCHAR2(25), Name VARCHAR2(25), Birthdate DATE);

• Creates a new type• CREATE TABLE Animal of Animal_ty;• Creates “Object Table”

Page 20: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 20

Constructor Functions• INSERT INTO Animal values

(ANIMAL_TY(‘Mule’, ‘Frances’, TO_DATE(‘01-APR-1997’, ‘DD-MM-YYYY’)));

• Insert a new ANIMAL_TY object into the table

Page 21: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 21

Selecting from an Object Table

• Just use the columns in the object…

• SELECT Name from Animal;

Page 22: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 22

More Complex Objects

• CREATE TYPE Address_TY as object (Street VARCHAR2(50), City VARCHAR2(25), State CHAR(2), zip NUMBER);

• CREATE TYPE Person_TY as object (Name VARCHAR2(25), Address ADDRESS_TY);

• CREATE TABLE CUSTOMER (Customer_ID NUMBER, Person PERSON_TY);

Page 23: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 23

What Does the Table Look like?

• DESCRIBE CUSTOMER;• NAME TYPE• -----------------------------------------------------• CUSTOMER_ID NUMBER• PERSON NAMED TYPE

Page 24: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 24

Inserting• INSERT INTO CUSTOMER VALUES (1,

PERSON_TY(‘John Smith’, ADDRESS_TY(‘57 Mt Pleasant St.’, ‘Finn’, ‘NH’, 111111)));

Page 25: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 25

Selecting from Abstract Datatypes

• SELECT Customer_ID from CUSTOMER;• SELECT * from CUSTOMER;

CUSTOMER_ID PERSON(NAME, ADDRESS(STREET, CITY, STATE ZIP))---------------------------------------------------------------------------------------------------1 PERSON_TY(‘JOHN SMITH’, ADDRESS_TY(‘57...

Page 26: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 26

Selecting from Abstract Datatypes

• SELECT Customer_id, person.name from Customer;

• SELECT Customer_id, person.address.street from Customer;

Page 27: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 27

Updating• UPDATE Customer SET

person.address.city = ‘HART’ where person.address.city = ‘Briant’;

Page 28: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 28

Functions• CREATE [OR REPLACE] FUNCTION

funcname (argname [IN | OUT | IN OUT] datatype …) RETURN datatype (IS | AS) {block | external body}

Page 29: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 29

ExampleCreate Function BALANCE_CHECK

(Person_name IN Varchar2) RETURN NUMBER is BALANCE NUMBER(10,2) BEGIN

SELECT sum(decode(Action, ‘BOUGHT’, Amount, 0)) - sum(decode(Action, ‘SOLD’, amount, 0)) INTO BALANCE FROM LEDGER where Person = PERSON_NAME;

RETURN BALANCE; END;

Page 30: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 30

Example• Select NAME, BALANCE_CHECK(NAME)

from Worker;

Page 31: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 31

TRIGGERS• Create TRIGGER UPDATE_LODGING

INSTEAD OF UPDATE on WORKER_LODGING for each row BEGIN

• if :old.name <> :new.name then update worker set name = :new.name where name = :old.name;

• end if;• if :old.lodging <> … etc...

Page 32: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 32

Lecture Outline• Final Project Requirements• Review

– Fourth Generation Languages– PHP implementation

• Object-Relational Extensions to SQL• Database Administration

Page 33: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 33

Today• Traditional and Current Data

Administration• Traditional and Current Database

Administration• Review of Security, Integrity, etc.

Page 34: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 34

Changes in Traditional Roles• This is being driven by rapid changes in

– Technology– Platforms (e.g., Micro vs. Mainframe vs.

Server)– Organizational Structure

• We will focus on the core functions and tasks of these roles (traditional or current)

Page 35: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 35

Terms and Concepts (trad)

• Data Administration– Responsibility for the overall management

of data resources within an organization• Database Administration

– Responsibility for physical database design and technical issues in database management

• These roles are often combined or overlapping in some organizations

Page 36: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 36

Terms and Concepts (trad)• DA

– Data adminstrator - person responsible for the Data Administration function in an organization

– Sometimes may be the CIO -- Chief Information Officer

• DBA– Database Administrator - person responsible

for the Database Administration Function

Page 37: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 37

Database System Life Cycle

Operation &Maintenance

DatabaseImplementation

DatabaseDesign

Growth &Change

DatabaseAnalysis

DatabasePlanning

Note: this is a different version of thislife cycle than discussed previously

Page 38: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 38

Database Planning• Development of a strategic plan for

database development that supports the overall organization’s business plan

• DA supports top management in development of this plan

• The result of this stage is an enterprise data model

Page 39: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 39

Database Planning: DA & DBA functions

• Develop corporate database strategy (DA)• Develop enterprise model (DA)• Develop cost/benefit models (DA)• Design database environment (DA)• Develop data administration plan (DA)

Page 40: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 40

Database Analysis• This is the process (discussed previously) of

identifying data entities currently used by the organization, precisely defining those entities and their relationships, and documenting the results in a form that can support the follow-on design phase

• Must also identify new data elements or changes to data elements that will be required in the future

• The result of this phase is the Conceptual Data Model -- usually represented as an ER diagram

Page 41: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 41

Database Analysis: DA & DBA functions

• Define and model data requirements (DA)• Define and model business rules (DA)• Define operational requirements (DA)• Maintain corporate Data Dictionary (DA)

Page 42: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 42

Database Design• Purpose of the design phase is the

development of the logical database design that will serve the needs of the organization and the physical design implementing the logical design

• In relational systems the outcome is normalized relations, and the data definition for a particular database systems (including indexes, etc.)

Page 43: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 43

Design 2: Physical Creation• Development of the Physical Model of the

Database– data formats and types– determination of indexes, etc.

• Load a prototype database and test• Determine and implement security, privacy

and access controls• Determine and implement integrity

constraints

Page 44: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 44

Database Design: DA &DBA functions

• Perform logical database design (DA)• Design external models (subschemas)

(DBA)• Design internal model (Physical design)

(DBA)• Design integrity controls (DBA)

Page 45: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 45

Database Implementation• Database design gives you an empty

database• Load data into the database structure• Convert existing data sets and

applications to use the new database– May need programs, conversion utilities to

convert old data to new formats.• Outcome is the actual database with its

data

Page 46: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 46

Database Implementation DA & DBA functions

• Specify database access policies (DA & DBA)• Establish Security controls (DBA)• Supervise Database loading (DBA)• Specify test procedures (DBA)• Develop application programming standards

(DBA)• Establish procedures for backup and recovery

(DBA)• Conduct User training (DA & DBA)

Page 47: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 47

Operation and Maintenance 1: Operations

• Users are responsible for updating the database, DA and DBA are responsible for developing procedures that ensure the integrity and security of the database during the update process.

• Specific responsibility for data collection, editing and verification must be assigned

• Quality assurance must be practiced to protect and audit the database quality.

Page 48: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 48

Operation and Maintenance 2: Maintenance

• The ongoing process of updating the database to keep it current – adding new records– deleting obsolete records– changing data values in particular records– modifying relation structures (e.g. adding new fields)

• Privacy, security, access control must be in place.

• Recovery and Backup procedures must be established and used

Page 49: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 49

Operation and Maintenance: DA & DBA functions

• Monitor database performance (DBA)• Tune and reorganize databases (DBA)• Enforce standards and procedures (DBA)• Support users (DA & DBA)

Page 50: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 50

Growth & Change• Change is a way of life

– Applications, data requirements, reports, etc. will all change as new needs and requirements are found

– The Database and applications and will need to be modified to meet the needs of changes to the organization and the environment

– Database performance should be monitored to maintain a high level of system performance

Page 51: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 51

Growth & Change: DA & DBA functions

• Implement change control procedures (DA & DBA)

• Plan for growth and change (DA & DBA)• Evaluate new technology (DA & DBA)

Page 52: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 52

Functions in Database Administration

• Planning and Design (we have already looked at theses processes in detail)

• REVIEW– Data Integrity– Backup and Recovery– Security Management

Page 53: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 53

Data Integrity• Intrarecord integrity (enforcing constraints

on contents of fields, etc.)• Referential Integrity (enforcing the validity

of references between records in the database)

• Concurrency control (ensuring the validity of database updates in a shared multiuser environment)

Page 54: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 54

No Concurrency Control: Lost updates

• Read account balance (balance = $1000)

• Withdraw $200 (balance = $800)

• Write account balance (balance = $800)

• Read account balance (balance = $1000)

• Withdraw $300 (balance = $700)

• Write account balance (balance = $700)

John Marsha

ERROR!

Page 55: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 55

Concurrency Control: Locking• Locking levels

– Database– Table– Block or page– Record– Field

• Types– Shared (S locks)– Exclusive (X locks)

Page 56: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 56

Concurrency Control: Updates with X locking

• Lock account balance• Read account balance

(balance = $1000)• Withdraw $200 (balance

= $800)• Write account balance

(balance = $800)• Unlock account balance

• Read account balance (DENIED)

• Lock account balance• Read account balance

(balance = $800)• etc...

John Marsha

Page 57: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 57

Concurrency Control: Deadlocks• Place S lock• Read account

balance (balance = $1000)

• Request X lock (denied)

• wait ...

• Place S lock• Read account balance

(balance = $1000)

• Request X lock (denied)

• wait...

John Marsha

Deadlock!

Page 58: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 58

Concurrency Control• Avoiding deadlocks by maintaining tables

of potential deadlocks and “backing out” one side of a conflicting transaction

Page 59: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 59

Database Security• Views or restricted subschemas• Authorization rules to identify users and

the actions they can perform• User-defined procedures (and rule

systems) to define additional constraints or limitations in using the database

• Encryption to encode sensitive data• Authentication schemes to positively

identify a person attempting to gain access to the database

Page 60: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 60

Views• A subset of the database presented to

some set of users– SQL: CREATE VIEW viewname AS SELECT

field1, field2, field3,…, FROM table1, table2 WHERE <where clause>;

– Note: “queries” in Access function as views

Page 61: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 61

Authorization Rules• Most current DBMS permit the DBA to

define “access permissions” on a table by table basis (at least) using the GRANT and REVOKE SQL commands

• Some systems permit finer grained authorization (most use GRANT and REVOKE on variant views

Page 62: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 62

Database Backup and Recovery

• Backup• Journaling (audit trail)• Checkpoint facility• Recovery manager

Page 63: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 63

Disaster Recovery Planning

Testing andTraining

ProceduresDevelopment

Budget &Implement

PlanMaintenance

RecoveryStrategies

RiskAnalysis

From Toigo “Disaster Recovery Planning”

Page 64: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 64

Threats to Assets and Functions

• Water• Fire• Power Failure• Mechanical breakdown or software failure• Accidental or deliberate destruction of

hardware or software– By hackers, disgruntled employees, industrial

saboteurs, terrorists, or others

Page 65: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 65

Threats• Between 1967 and 1978 fire and water

damage accounted for 62% of all data processing disasters in the U.S.

• The water damage was sometimes caused by fighting fires

• More recently improvements in fire suppression (e.g., Halon) for DP centers has meant that water is the primary danger to DP centers

Page 66: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 66

Kinds of Records• Class I: VITAL

– Essential, irreplaceable or necessary to recovery• Class II: IMPORTANT

– Essential or important, but reproducible with difficulty or at extra expense

• Class III: USEFUL– Records whose loss would be inconvenient, but which

are replaceable• Class IV: NONESSENTIAL

– Records which upon examination are found to be no longer necessary

Page 67: Data Administration and Database Administration

IS 257 – Spring 2004 2004.03.18- SLIDE 67

Offsite Storage of Data• Early offsite storage facilities were often

intended to survive atomic explosions• PRISM International directory • Mirror sites (Hot sites)