Download presentation
Presentation is loading. Please wait.
1
2002.10.31- SLIDE 1IS 257 - Fall 2002 Fourth Generation Languages and OR extensions to SQL University of California, Berkeley School of Information Management and Systems SIMS 257: Database Management
2
2002.10.31- SLIDE 2IS 257 - Fall 2002 Lecture Outline Review: Security and Integrity Fourth Generation Languages Object-Relational Extensions to SQL
3
2002.10.31- SLIDE 3IS 257 - Fall 2002 Security and Integrity Functions in Database Administration Data Integrity Security Management Backup and Recovery
4
2002.10.31- SLIDE 4IS 257 - Fall 2002 Security and Integrity Functions in Database Administration Data Integrity Security Management Backup and Recovery
5
2002.10.31- SLIDE 5IS 257 - Fall 2002 Integrity Constraints (review) The constraints we wish to impose in order to protect the database from becoming inconsistent. Five types –Required data –attribute domain constraints –entity integrity –referential integrity –enterprise constraints
6
2002.10.31- SLIDE 6IS 257 - Fall 2002 Data and Domain Integrity This is now increasing handled by the database. In Oracle, for example, when defining a table you can specify: CREATE TABLE table-name ( attr2 attr-type NOT NULL, forbids NULL values attrN attr-type CHECK (attrN = UPPER(attrN) verifies that the data meets certain criteria attrO attr-type DEFAULT default_value); Supplies default values
7
2002.10.31- SLIDE 7IS 257 - Fall 2002 Referential Integrity Ensures that dependent relationships in the data are maintained. In Oracle, for example: CREATE TABLE table-name ( attr1 attr-type PRIMARY KEY, attr2 attr-type NOT NULL, …, attrM attr-type REFERENCES owner.tablename(attrname) ON DELETE CASCADE, …
8
2002.10.31- SLIDE 8IS 257 - Fall 2002 Concurrency Control The goal is to support access by multiple users to the same data, at the same time It must assure that the transactions are serializable and that they are isolated It is intended to handle several problems in an uncontrolled system Specifically: –Lost updates –Inconsistent data states during access –Uncompleted (or committed) changes to data
9
2002.10.31- SLIDE 9IS 257 - Fall 2002 Transaction Control in ORACLE Transactions are sequences of SQL statements that ORACLE treats as a unit –From the user’s point of view a private copy of the database is created for the duration of the transaction Transactions are started with SET TRANSACTION, followed by the SQL statements Any changes made by the SQL are made permanent by COMMIT Part or all of a transaction can be undone using ROLLBACK
10
2002.10.31- SLIDE 10IS 257 - Fall 2002 Transactions in ORACLE COMMIT; SET TRANSACTION READ ONLY; SELECT NAME, ADDRESS FROM WORKERS; SELECT MANAGER, ADDRESS FROM PLACES; COMMIT; Freezes the data for the user in both tables before either select retrieves any rows, so that changes that occur concurrently will not show up Commits before and after ensure any uncompleted transactions are finish, and then release the frozen data when done
11
2002.10.31- SLIDE 11IS 257 - Fall 2002 Transactions in ORACLE Savepoints are places in a transaction that you may ROLLBACK to (called checkpoints in other DBMS) –SET TRANACTION…; –SAVEPOINT ALPHA; –SQL STATEMENTS… –IF (CONDITION) THEN ROLLBACK TO SAVEPOINT ALPHA; –SAVEPOINT BETA; –SQL STATEMENTS… –IF …; –COMMIT;
12
2002.10.31- SLIDE 12IS 257 - Fall 2002 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
13
2002.10.31- SLIDE 13IS 257 - Fall 2002 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 ; –Note: “queries” in Access function as views
14
2002.10.31- SLIDE 14IS 257 - Fall 2002 Restricted Views Main relation has the form: Name C_name Dept C_dept Prof C_prof TC J SmithSDept1SCryptographyTS M DoeUDept2SIT SecuritySS R JonesUDept3USecretaryUU U = unclassified : S = Secret : TS = Top Secret
15
2002.10.31- SLIDE 15IS 257 - Fall 2002 Restricted Views NAMEDeptProf J SmithDept1--- M DoeDept2IT Security R JonesDept3Secretary NAMEDeptProf M Doe--- R JonesDept3Secretary S-view of the data U-view of the data
16
2002.10.31- SLIDE 16IS 257 - Fall 2002 Disaster Recovery Planning Testing and Training Procedures Development Budget & Implement Plan Maintenance Recovery Strategies Risk Analysis From Toigo “Disaster Recovery Planning”
17
2002.10.31- SLIDE 17IS 257 - Fall 2002 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
18
2002.10.31- SLIDE 18IS 257 - Fall 2002 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
19
2002.10.31- SLIDE 19IS 257 - Fall 2002 Lecture Outline Review: Security and Integrity Fourth Generation Languages Object-Relational Extensions to SQL
20
2002.10.31- SLIDE 20IS 257 - Fall 2002 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??
21
2002.10.31- SLIDE 21IS 257 - Fall 2002 Chauffeurs In the early days of the US car industry, production volumes were growing fast, and a well-known sociologist was asked to predict the total number of automobiles that would ever be manufactured. After a great deal of study, the sociologist reported that no more than 2 million would be manufactured in the life cycle of the car. If the car lasted ten years on average, the maximum annual production would never exceed 200,000. This conclusion was based on the much-researched figure that no more than 2 million people would be willing to serve as chauffeurs. From James Martin - Fourth Generation Languages
22
2002.10.31- SLIDE 22IS 257 - Fall 2002 Fourth Generation Languages In the database environment these are used for creation of database applications To speed up the application building process To make applications easy and quick to change To minimize debugging problems To generate bug-free code from high-level expressions of requirement To make languages user-friendly so that “end- users” can solve their own problems and put computers to work.
23
2002.10.31- SLIDE 23IS 257 - Fall 2002 Basic Principles of 4GLs The Principle of Minimum Work The Principle of Minimum Skill The Principle of avoiding alien syntax and mnemonics The Principle of Minimum Time The Principle of Minimum errors The Principle of Minumum Maintenance The Principle of Maximum Results From James Martin - Fourth Generation Languages
24
2002.10.31- SLIDE 24IS 257 - Fall 2002 Properties of 4GLs User Friendly A nonprofessional programmer can obtain results with it It employs the database management system directly Programs for most applications can be created with 10 times fewer instructions than in a Third Generation Language
25
2002.10.31- SLIDE 25IS 257 - Fall 2002 More Properties of 4GLs Non procedural code is used wherever possible It make intelligent default assumptions about what the user wants wherever possible It is designed for online operation It enforces or encourages structured code It makes it easy to understand and maintain another person’s code
26
2002.10.31- SLIDE 26IS 257 - Fall 2002 More Properties of 4GLs Non-DP users can learn a subset of the language in a short course It is designed for easy debugging Prototypes can be created and modified quickly Results can be obtained in an order of magnitude less time than with a 3GL for most applications
27
2002.10.31- SLIDE 27IS 257 - Fall 2002 Selection Criteria for 4GLs Is it intended for routine computing of ad hoc decision making Is it intended for end users or DP professionals? (many 4GLs are appropriate for both) Does it require the skills of a programmer, or can an analyst who does not program in a 3GL use it.
28
2002.10.31- SLIDE 28IS 257 - Fall 2002 Selection Criteria for 4GLs Which of the following features does it provide? –Simple queries –Simple queries and updates –Complex queries –Complex queries and updates –The ability to create a database quickly –Intelligent database operations, where the change of one value in the database causes other operations to occur automatically, such as validity checks, cross references, and the updating of related values.
29
2002.10.31- SLIDE 29IS 257 - Fall 2002 Selection Criteria for 4GLs Which of the following features does it provide?(cont) –Generation of data-entry screens for key-entry operators (with validity checks) –Generation of data-update screens for key-entry operators (with validity checks) –A procedural language giving full programming capability –Graphics techniques for application design –Spreadsheet manipulation –Multidimensional matrix manipulation –Report generation –Graphics generation
30
2002.10.31- SLIDE 30IS 257 - Fall 2002 Selection Criteria for 4GLs Which of the following features does it provide?(cont) –Graphics manipulation –Decision support for what-if questions –Mathematical analysis tools –Financial analysis tools –Other decision-support tools –Text manipulation –Electronic Mailbox Is it on-line or off-line? Does it run on mainframes, minicomputers or personal computers? Can it access mainframe or remote databases Is it genuinely easy to use Can results be obtained with it very quickly?
31
2002.10.31- SLIDE 31IS 257 - Fall 2002 Components of a 4GL Application Parameters Testing tools/debugger Interpreter Optimizing compiler Rules Specification Data Specification Report Specification Screen Specification Procedural facility Feedback for building routine applications…
32
2002.10.31- SLIDE 32IS 257 - Fall 2002 5GLs -- Natural Language Possibilities Problems
33
2002.10.31- SLIDE 33IS 257 - Fall 2002 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
34
2002.10.31- SLIDE 34IS 257 - Fall 2002 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
35
2002.10.31- SLIDE 35IS 257 - Fall 2002 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
36
2002.10.31- SLIDE 36IS 257 - Fall 2002 Assumptions and Issues Why 4GLs? –Are they still appropriate? –Are they still useful? Is Cold Fusion a 4GL? What about PHP? Who needs them?
37
2002.10.31- SLIDE 37IS 257 - Fall 2002 Object Relational Databases Background Object Definitions –inheritance User-defined datatypes User-defined functions
38
2002.10.31- SLIDE 38IS 257 - Fall 2002 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)
39
2002.10.31- SLIDE 39IS 257 - Fall 2002 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
40
2002.10.31- SLIDE 40IS 257 - Fall 2002 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
41
2002.10.31- SLIDE 41IS 257 - Fall 2002 Object-Relational SQL in ORACLE CREATE (OR REPLACE) TYPE typename AS OBJECT (attr_name, attr_type, …); CREATE TABLE OF typename;
42
2002.10.31- SLIDE 42IS 257 - Fall 2002 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”
43
2002.10.31- SLIDE 43IS 257 - Fall 2002 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
44
2002.10.31- SLIDE 44IS 257 - Fall 2002 Selecting from an Object Table Just use the columns in the object… SELECT Name from Animal;
45
2002.10.31- SLIDE 45IS 257 - Fall 2002 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);
46
2002.10.31- SLIDE 46IS 257 - Fall 2002 What Does the Table Look like? DESCRIBE CUSTOMER; NAME TYPE ----------------------------------------------------- CUSTOMER_ID NUMBER PERSON NAMED TYPE
47
2002.10.31- SLIDE 47IS 257 - Fall 2002 Inserting INSERT INTO CUSTOMER VALUES (1, PERSON_TY(‘John Smith’, ADDRESS_TY(‘57 Mt Pleasant St.’, ‘Finn’, ‘NH’, 111111)));
48
2002.10.31- SLIDE 48IS 257 - Fall 2002 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...
49
2002.10.31- SLIDE 49IS 257 - Fall 2002 Selecting from Abstract Datatypes SELECT Customer_id, person.name from Customer; SELECT Customer_id, person.address.street from Customer;
50
2002.10.31- SLIDE 50IS 257 - Fall 2002 Updating UPDATE Customer SET person.address.city = ‘HART’ where person.address.city = ‘Briant’;
51
2002.10.31- SLIDE 51IS 257 - Fall 2002 Functions CREATE [OR REPLACE] FUNCTION funcname (argname [IN | OUT | IN OUT] datatype …) RETURN datatype (IS | AS) {block | external body}
52
2002.10.31- SLIDE 52IS 257 - Fall 2002 Example Create 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;
53
2002.10.31- SLIDE 53IS 257 - Fall 2002 Example Select NAME, BALANCE_CHECK(NAME) from Worker;
54
2002.10.31- SLIDE 54IS 257 - Fall 2002 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...
55
2002.10.31- SLIDE 55IS 257 - Fall 2002 Next Week Database Administration More on Database Applications
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.