Professional Documents
Culture Documents
Integrity Security
Integrity Security
Integrity Security
Database
Module 4
Integrity and Security in Database
Domain Constraints
Referential integrity
Assertions
Trigger
Security
Authorization in SQL
Transactions
Transaction is a Unit of work
It consists of sequence of query and/or update statements.
Atomic transaction
automatically
Integrity Constraints
Integrity constraints guard against accidental damage to
the database, by ensuring that authorized changes
to the database do not result in a loss of data consistency.
Domain Constraints
Referential Integrity
Assertions
Triggers
Functional Dependencies
Domain Constraints
They define valid values for attributes.
They are the most elementary form of integrity
constraint.
They test values inserted in the database, and test
Unique
unique ( A1, A2, …, Am)
The unique specification states that the attributes A1, A2, … Am form a
candidate key.
Candidate keys are permitted to be null (in contrast to primary keys).
Constraints
Primary key
o Combination of unique and not null. i.e. each row
should have known distinct value.
emp_id number(10) primary key;
Default
o It specifies the default value for a column using default
clause.
o The default value for column is inserted for a row, when
l
Check clause can also be applied to domain
declarations.
l
Eg: A domain can be restricted to contain only a
specified set of value by using the in clause.
l
Create domain AccountType char(10)
l
constraint account-type-test
l
check (value in ('Checking','saving'));
Referential Integrity
Ensures that a value that appears in one relation for a
given set of attributes also appears for a certain set of
attributes in another relation.
Semantics
When the Event occurs and Condition is true, execute the
Action
Twotriggering times
Before the event
After the event
Twogranularities
Execute for each row
Execute for each statement
1) Trigger: Event
Trigger name
Create Trigger <name>
Before|After Insert|Update|Delete ON <tablename> That is the event
….
Example
Create Trigger ABC Create Trigger XYZ
Before Insert On Students After Update On Students
…. ….
When <condition>
…
That is the condition
In
the action, you may want to reference:
The new values of inserted or updated records (:new)
The old values of deleted or updated records (:old)
Trigger: Referencing Values
In the action, you may want to reference:
The new values of inserted or updated records (:new)
The old values of deleted or updated records (:old)
to database systems.
privileges.
The privilege all privileges can be used as a short form to
list>
Eg: grant select on account to John,Mary
Eg: grant select on account to teller
<user/role list>
Eg: revoke select on account to John,Mary
Security in Database
Security is protection from malicious attempts to steal or
modify data.
Security should be provided at following levels: