3 Data Control
3 Data Control
Systems
TS. Phan Thị Hà
◼ Involves:
❑ View management
❑ Security control
❑ Integrity control
◼ Objective :
❑ Ensure that authorized users perform correct operations on the
database, contributing to the maintenance of the database
integrity.
Example :
SELECT ENAME,PNO,RESP
FROM EMP, ASG
WHERE EMP.ENO = ASG.ENO
AND TITLE = "Syst. Anal."
◼ To restrict access
CREATE VIEW ESAME
AS SELECT *
FROM EMP E1, EMP E2
WHERE E1.TITLE = E2.TITLE
AND E1.ENO = USER
◼ Query
SELECT *
FROM ESAME
◼ Updatable
CREATE VIEW SYSAN(ENO,ENAME)
AS SELECT ENO,ENAME
FROM EMP
WHERE TITLE="Syst. Anal."
◼ Non-updatable
CREATE VIEW EG(ENAME,RESP)
AS SELECT ENAME,RESP
FROM EMP, ASG
WHERE EMP.ENO=ASG.ENO
◼ Immediate mode
❑ As part of the updating transaction, e.g. through 2PC
❑ View always consistent with base data and fast queries
❑ But increased transaction time to update base data
◼ Deferred mode (preferred in practice)
❑ Through separate refresh transactions
◼ No penalty on the updating transactions
❑ Triggered at different times with different trade-offs
◼ Lazily: just before evaluating a query on the view
◼ Periodically: every hour, every day, etc.
◼ Forcedly: after a number of predefined updates
◼ Basic idea
❑ Maintain a count of the number of derivations for each tuple in
the view
❑ Increment (resp. decrement) tuple counts based on insertions
(resp. deletions)
❑ A tuple in the view whose count is zero can be deleted
◼ Algorithm
1. Compute V+ and V- using V, base relations and diff. relations
2. Compute positive in V+ and negative counts in V-
3. Compute V+ (V – V- ), deleting each tuple in V with count=0
◼ Optimal: computes exactly the view tuples that are
inserted or deleted
© 2020, M.T. Özsu & P. Valduriez TS.
19
Phan Thị Hà
Exploiting Data Skew
◼ Basic idea
❑ Partition the relations on heavy / light values for join attributes
◼ Threshold depends on data size and user parameter
❑ Maintain the join of different parts using different plans
◼ Most cases done using delta processing (Counting)
◼ Few cases require pre-materialization of auxiliary views
❑ Rebalance the partitions to reflect heavy ↔ light changes
◼ Reasons for change:
❑ Much more/less occurrences of a value than before
❑ The heavy/light threshold changes due to change in data size
◼ Update times are amortized to account for occasional rebalancing
◼ Maintenance time:
❑ Updates to R: O(1) time to look up in VST
❑ Updates to S and T: O(N) time to maintain VST
◼ Extra O(N2) space needed for the view VST
◼ Cardinality bounds
❑ For every value a’: 𝜎𝑎=𝑎′ 𝑅𝐿 < 𝑁 𝜀
❑ 𝜋𝑎 𝑅𝐻 ≤ 𝑁1−𝜀
◼ Maintenance time
❑ O(1) for the skew-aware view
❑ 𝑂(𝑁 m𝑎𝑥{𝜀,1−𝜀} ) for the auxiliary view
◼ Size of auxiliary view: 𝑂(𝑁 1+m𝑖𝑛{𝜀,1−𝜀} )
© 2020, M.T. Özsu & P. Valduriez TS.
31
Phan Thị Hà
View Self-maintainability
❑ Data security
❑
◼ Data protection
❑ Prevents the physical content of data to be understood by
unauthorized users
❑ Uses encryption/decryption techniques (Public key)
◼ Access control
❑ Only authorized users perform operations they are allowed to on
database objects
❑ Discretionary access control (DAC)
◼ Long been provided by DBMS with authorization rules
❑ Multilevel access control (MAC)
◼ Increases security with security levels
◼ Main actors
❑ Subjects (users, groups of users) who execute operations
❑ Operations (in queries or application programs)
❑ Objects, on which operations are performed
◼ Checking whether a subject may perform an op. on an
object
❑ Authorization= (subject, op. type, object def.)
❑ Defined using GRANT OR REVOKE
❑ Centralized: one single user class (admin.) may grant or revoke
❑ Decentralized, with op. type GRANT
◼ More flexible but recursive revoking process which needs the hierarchy
of grants
◼ Behavioral constraints
❑ Regulate application behavior, e.g., dependencies in the
relational model
◼ Two components
❑ Integrity constraint specification
❑ Integrity constraint enforcement
© 2020, M.T. Özsu & P. Valduriez TS.
43
Phan Thị Hà
Semantic Integrity Control
◼ Procedural
❑ Control embedded in each application program
◼ Declarative
❑ Assertions in predicate calculus
❑ Easy to define constraints
❑ Definition of database consistency clear
❑ But inefficient to check assertions for each update
◼ Limit the search space
◼ Decrease the number of data accesses/assertion
◼ Preventive strategies
◼ Checking at compile time
Precompiled constraints
Express preconditions that must be satisfied by all tuples in a
relation for a given update type
(INSERT, DELETE, MODIFY)
NEW - ranges over new tuples to be inserted
OLD - ranges over old tuples to be deleted
General Form
CHECK ON <relation> [WHEN <update type>]
<qualification>
Precompiled constraints
❑ Domain constraint
❑ Transition constraint
General constraints
Constraints that must always be true. Formulae of tuple
relational calculus where all variables are quantified.
General Form
CHECK ON <variable>:<relation>,(<qualification>)
❑ Functional dependency
CHECK ON e1:EMP, e2:EMP
(e1.ENAME = e2.ENAME IF e1.ENO = e2.ENO)
❑ Constraint with aggregate function
CHECK ON g:ASG, j:PROJ
(SUM(g.DUR WHERE g.PNO = j.PNO) < 100 IF
j.PNAME = "CAD/CAM")
Two methods
◼ Detection
Execute update u: D → Du
If Du is inconsistent then
if possible: compensate Du → Du’
else
undo Du → D
◼ Preventive
Execute u: D → Du only if Du will be consistent
❑ Determine valid programs
◼ Preventive
◼ Add the assertion qualification to the update query
◼ Only applicable to tuple calculus formulae with
universally quantified variables
UPDATE PROJ
SET BUDGET = BUDGET*1.1
WHERE PNAME = "CAD/CAM"
UPDATE PROJ
SET BUDGET = BUDGET*1.1
WHERE PNAME = "CAD/CAM"
AND NEW.BUDGET ≥ 500000
AND NEW.BUDGET ≤ 1000000
Type of u
insert R- empty
delete R+ empty
modify R+ (R – R-)
◼ Problems:
❑ Definition of constraints
◼ Consideration for fragments
❑ Where to store
◼ Replication
◼ Non-replicated : fragments
❑ Enforcement
◼ Minimize costs
◼ Individual assertions
❑ Single relation, single variable
❑ Domain constraint