Presentation is loading. Please wait.

Presentation is loading. Please wait.

ON RULES, PROCEDURES, CACHING AND VIEWS IN DATA BASE SYSTEM by M. Stonebraker, A. Jhingran, J. Goh, and S. Potamianos UC Berkley Presented by Zhou Ji.

Similar presentations


Presentation on theme: "ON RULES, PROCEDURES, CACHING AND VIEWS IN DATA BASE SYSTEM by M. Stonebraker, A. Jhingran, J. Goh, and S. Potamianos UC Berkley Presented by Zhou Ji."— Presentation transcript:

1 ON RULES, PROCEDURES, CACHING AND VIEWS IN DATA BASE SYSTEM by M. Stonebraker, A. Jhingran, J. Goh, and S. Potamianos UC Berkley Presented by Zhou Ji

2 Main idea of the paper: A rule system is a fundamental concept in a next generation DBMS, and it subsumes both views and procedures as special cases. Background: POSTGRES system the second POSTGRES rule system (PRS2)

3 1. What is view and procedure data type? What is view? View is a virtual relation that is defined on other relations, all queries and updates to which can be mapped to commands on the underlying base relation. Example: define view TOY_EMP as retrieve (EMP name, EMP age, EMP salary) where EMP dept = toy

4 What is the procedure data type? Data type of a column in a relation, each of which is an unrestricted collection of query language commands. Example: EMP(name, hobbies) Hobby relations: SOFTBALL(name, position, average) JOGGING(name, mile, best-time)

5 Define procedure foobar for employee Joe: retrieve (SOFTBALL all) where SOFTBALL name=Joe retrieve (JOGGING all) where JOGGING name =Joe Insert a record of Joe to EMP: append to EMP (name=Joe, hobbies=foobar)

6 2. The form of PRS2 DEFINE RULE rule-name [AS EXCEPTION rule-name] ON event TO object [[FROM clause] WHERE clause] THEN DO [instead] action NEW and CURRENT can appear instead of a tuple variable whenever a tuple is permissible.

7 Example 1 define rule example_1 on replace to EMP salary where EMP name = Joe then replace EMP (salary = NEW salary) where EMP name = Sam Whenever Joes salary is changed, Sam gets the same salary. define rule example_2 on retrieve to EMP salary where EMP name = Joe then replace EMP (salary = CURRENT salary) where EMP name = Bill

8 Example 3 define rule example_3 on retrieve to EMP salary where EMP dept = shoe and user() = Joe then do instead retrieve (salary = null) Joe is not allowed to see the salary of employees in the shoe department. define rule example_4 on retrieve to EMP salary where EMP dept = shoe and user() = Joe then do replace CURRENT (salary = null)

9 Example 8 define rule example_8 on retrieve to TOY_EMP then do instead retrieve (EMP-OID = EMP-OID, EMP name, EMP age, EMP salary) where (EMP dept = toy) This specifies a view - retrieving from the view TOY_EMP is mapped to the underlying base relation EMP.

10 3. How does the rule system simulate view and procedure? Procedure definition in POSTGRES define [updated] procedure proc- name (type-1,, type-2) as postquel-commands Without parameters, it is a view definition define [updated] view view-name as postquel-commands

11 Example define [updated] view TOP_EMP as retrieve (EMP name, EMP age, EMP salary) where EMP dept = toy The system construct the following rules in addition to example_8 to simulate the view define rule TOP_EMP_d on delete to TOY_EMP then do instead delete EMP where EMP OID=CURRENT EMP_OID define rule TOP_EMP_a on append to TOY_EMP then do instead append EMP (name=NEW name, age=NEW age, salary=NEW salary, dept=toy) define rule TOP_EMP_r on replace to TOY_EMP then do instead replace EMP (name=NEW name, age=NEW age, salary=NEW salary, dept=toy) where EMP OID=CURRENT EMP_OID

12 Rule to support procedure data type on retrieve to rel-name column-name where rel-name OID=value then do instead execute proc-name(parameter- list) Example append to EMP (name=Sam, hobbies=foolbar(param-1,,param-n)) Simulated by append to EMP (name=Sam) define rule example_17 on retrieve to EMP hobbies where EMP OID=value then do instead execute foobar(param-1,,param- n)

13 One general purpose rules system supports all the following concepts. Views special semantics for updating views materialized views partial views procedures special procedures caching of procedures

14 4. Implementation and caching Implementation –tuple level –query rewrite caching three cases –(1) object: relation, event: no where clause –(2) object: relation-name field, event : no where clause –(3) there is a where clause

15 Examples Consider example_8 and incoming query retrieve (TOY_EMP salary) where TOY_EMP name=Sam Rewrite the query to retrieve (EMP salary) where EMP name=Sam and EMP dept=toy

16 5. Conclusions It is recommend that implementers concentrate on a single powerful rules system and then simulate all of the various concepts using the rules system. Semantics of CURRENT and NEW attributes is enforced by tuple level implementation, or removed by query rewriting.

17 conclusions Non-standard update semantics can be specified as additional updating rule, thereby substantially enhancing the power of views. POSTGRES procedures are merely an additional application of the rule system. Caching of rules naturally supports materialized views and cached procedures, thereby no extra mechanism are required to obtain this functionality.


Download ppt "ON RULES, PROCEDURES, CACHING AND VIEWS IN DATA BASE SYSTEM by M. Stonebraker, A. Jhingran, J. Goh, and S. Potamianos UC Berkley Presented by Zhou Ji."

Similar presentations


Ads by Google