Docsity

Semantic Data Control-Distributed Database-Lecture 04 Slides-Computer Science, Appunti di Basi di Dati

Anteprima parziale del testo

Scarica Semantic Data Control-Distributed Database-Lecture 04 Slides-Computer Science e più Appunti in PDF di Basi di Dati solo su Docsity!

Chapter 4: Semantic Data Control

Acknowledgements: • Integrity control • Security control • View management

(^) I am indebted to Arturas Mazeika for providing me his slides of the last year course.

J. Gamper

Semantic Data Control

  • (^) Informally, these functions must ensure thatsemantic integrity control. • (^) Semantic data control typically includes view management, security control, and

(^) authorized (^) users perform

(^) correct

operations on the database, contributing to the maintenance of database

(^) integrity .

-^ •^ In RDBMS semantic data control can be achieved in a uniform way that the system automatically enforcesviews, security constraints, and semantic integrity constraints can be defined as rules

J. Gamper

View Management in Centralized Databases

  • (^) Example: • (^) It can involve selection, projection, aggregate functions, etc. • (^) A view is a relation that is derived from a base relation via a query. (^) The view of system analysts derived from relation EMP CREATE VIEW

SYSAN(ENO,ENAME)

AS

SELECT

ENO,ENAME

FROM

EMP

WHERE

TITLE="Syst. Anal."

J. Gamper

View Management in Centralized Databases...

  • (^) Example • (^) Queries expressed on views are translated into queries expressed on base relations : “Find the names of all the system analysts with their project number and

SELECT^ –^ Involves the view SYSAN and the relation ASG(ENO,PNO,RESP,DUR)responsibility?”

ENAME, PNO, RESP

FROM

SYSAN, ASG

WHERE

SYSN.ENO =

ASG.ENO

SELECT^ is translated into

ENAME,PNO,RESP

FROM

EMP, ASG

WHERE

EMP.ENO = ASG.ENO

AND

TITLE =

"Syst. Anal."

qualification^ •^ Automatic query modification is required, i.e., ANDing query qualification with view

J. Gamper

View Management in Centralized Databases...

  • (^) Non-updatable view:

(^) The updates to the view

(^) cannot (^) be propagated to the base

relations without ambiguity. CREATE VIEW

EG(ENAME,RESP)

AS
SELECT

ENAME,RESP

FROM

EMP, ASG

WHERE

EMP.ENO=ASG.ENO

of views, e.g., joins^ –^ However, it is theoretically possible to automatically support updates of a larger classprojection^ –^ Views can be updated only if they are derived from a single relation by selection and^ •^ Current systems are very restrictive about supportin gupdates through viewsdecide.EMP and deletion of “Syst. Anal.” in ASG are both meaningful, but the system cannot^ –^ e.g, deletion of (Smith, ”Syst. Anal.”) is ambiguous, i.e., since deletion of “Smith” in

J. Gamper

View Management in Distributed Databases

-^ •^ Definition of views in DDBMS is similar as in centralized DBMS different sitesHowever, a view in a DDBMS may be derived from fragmented relations stored at - (possibly) distributed directory/catalogue^ •^ Views are conceptually the same as the base relations, therefore we store them in the queries due to possible fragmentation of data^ –^ Queries on views are translated into queries on base relations, yielding distributedThus, views might be centralized at one site, partially replicated, fully replicated -^ •^ Views derived from distributed relations may be costly to evaluate

∗ is subject to periodic recalculation ∗ typically used when selectivity is small (no indices can be used efficiently) ∗ managed as temporary relations: the only access path is sequential scan ∗ does not reflect the updates to the base relations^ –^ A snapshot is a static viewOptimizations are important, e.g., snapshots

J. Gamper

Data Protection

  • (^) Data protection

(^) prevents unauthorized users from understanding the physical content of

- (^) Public-key encryption schemes – (^) Data encryption standard^ •^ Well established standards existdata.

J. Gamper

Authorization Control

  • (^) Authorization control

(^) must guarantee that only authorized users perform operations

- users^ •^ Three actors are involved in authorizationthey are allowed to perform on the database. , who trigger the execution of application programms - operations , which are embedded in applications programs - database objects

, on which the operations are performed

  • (^) Authorization control can be viewed as a triple

(^) (user, operation type, object)

(^) which

- (^) In a DBMS: Data objects are views, (fragments of) relations, tuples, attributes – (^) In a file system: data objects are files^ •^ Authorization control in (D)DBMS is more complicated as in operating systems^ •^ Authentication of (groups of) users is typically done by username and passwordobject.specifies that the user has the right to perform an operation of operation type on an

J. Gamper

Distributed Authorization Control

  • (^) Additional problems of

(^) authorization control in a distributed environment

(^) stem from

  • (^) Remote user authentication – (^) handling of views and of user groups – (^) managmenet of distributed authorization rules – (^) remote user authenticationthe fact that objects and subjects are distributed:

(^) is necessary since any site of a DDBMS may accept

∗ sites, whenever the relations at remote sites are accessed^ –^ (username, password) is replicated at all sites and are communicated between the^ •^ Two solutions are possible:programs initiated and authorized at remote sites

beneficial if the users move from a site to a site

∗^ –^ All sites of the DDBMS identify and authenticate themselves similarly as users do

∗ beneficial if users are staticstart site has been authenticated ∗ no remote user authentication is required for accessing remote relations once the ∗ (username, password) is authorized by application at the start of the session;intersite communication is protected by the use of the site password;

J. Gamper

Semantic Integrity Constraints

  • (^) A database is said to be

(^) consistent (^) if it satisfies a set of constraints, called

(^) semantic

- Structural constraints^ •^ Two main types of constraints can be distinguished:procedural methods – (^) avoid data dependency problem, code redundancy, and poor performance of theembedded in application programs) to declarative methods^ •^ Semantic integrity control evolved from procedural methods (in which the controls were^ •^ Maintain a database consistent by enforcing a set of constraints is a difficult problem integrity constraints

: basic semantic properties inherent to a data model e.g.,

- Behavioral constraints unique key constraint in relational model

: regulate application behavior e.g., dependencies

(functional, inclusion) in the relational model

-^ •^ A semantic integrity control system has 2 components: - (^) Integrity constraint enforcementIntegrity constraint specification

J. Gamper

Semantic Integrity Constraint Specification...

  • (^) Predefined constraints

(^) are based on simple keywords and specify the more common

ENO^ –^ e.g., Employee number in EMP cannot be null^ •^ Not-null attribute:contraints of the relational model

NOT NULL

IN

EMP

-^ •^ Unique key:

(ENO, PNO)e.g., the pair (ENO,PNO) is the unique key in ASG

UNIQUE IN

ASG

-^ •^ Foreign key:

PNOe.g., PNO in ASG is a foreign key matching the primary key PNO in PROJ

IN

ASG

REFERENCES

PNO IN PROJ

-^ •^ Functional dependency:

ENOe.g., employee number functionally determines the employee name

IN

EMP

DETERMINES

ENAME

J. Gamper

Semantic Integrity Constraint Specification...

  • (^) Precompiled constraints

(^) express preconditions that must be satisfied by all tuples in a

CHECK ON^ •^ General form:relation for a given update type

[

WHEN

]

CHECK ON^ •^ Domain constraint, e.g., constrain the budget:

PROJ(BUDGET

AND

BUDGET

CHECK ON^ •^ Domain constraint on deletion, e.g., only tuples with budget 0 can be deleted:

PROJ

WHEN
DELETE

(BUDGET = 0)

CHECK ON^ •^ Transition constraint, e.g., a budget can only increase:

PROJ (NEW.BUDGET >

OLD.BUDGET

AND

NEW.PNO =

OLD.PNO)

update^ –^ OLD and NEW are implicitly defined variables to identify the tuples that are subject to

J. Gamper

Semantic Integrity Constraints Enforcement

  • (^) Enforcing semantic integrity constraints

(^) consists of rejecting update programs that

  • (^) Thereby, the major problem is to findviolate some integrity constraints

(^) efficient algorithms

- Detection:^ •^ Two methods to enforce integrity constraints:

  1. Execute update

u : D

→ D

u

2. If D

u (^) is inconsistent then compensate

u D

→ D

u (^) or undo′

u D

→ D

∗ Also called

(^) posttest

Execute^ – Prevention:^ ∗ May be costly if undo is very large

u : D

→ D

u (^) only if

u D

will be consistent

∗ Also called

(^) pretest

· particularly efficient in enforcing domain constraints.^ ∗^ Query modification algorithm by Stonebraker (1975) is a preventive method that is^ ∗^ Generally more efficient

immediately for each tupleAdd the assertion qualification (constraint) to the update query and check it

J. Gamper

Semantic Integrity Constraints Enforcement...

  • (^) Example

UPDATE : Consider a query for increasing the budget of CAD/CAM projects by 10%:

PROJ

SET

BUDGET =

BUDGET * 1.

WHERE

PNAME = ‘‘CAD/CAM’’

and the domain constraint

CHECK ON

PROJ (BUDGET >=

50K

AND

BUDGET <= 100K)

The query modification algorithm transforms the query into:

UPDATE

PROJ

SET

BUDGET =

BUDGET * 1.

WHERE

AND NEW.BUDGET <= 100KAND NEW.BUDGET >= 50K^ PNAME = ‘‘CAD/CAM’’

J. Gamper