Docsity

Database Integrity and Security: Ensuring Data Consistency and Protection, Slides of Database Management Systems (DBMS)

Partial preview of the text

Download Database Integrity and Security: Ensuring Data Consistency and Protection and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Chapter 6:

Integrity and Security

Integrity!

  • Integrity constraints

ensure that changes made to the database by authorized users do not result in loss of data consistency.

Creating New Domains

  • The ‘create domain’ clause allows you to

create your own domain types.

  • EX1: create domain Dollars numeric(12,2)
    • These create numerical domains with 12 total digits, two of which are after the decimal point.

Referential Integrity

  • Ensuring 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.

  • EX1: In a banking system, the attribute

branch-name in Account-Schema is a foreign

key referencing the primary key of Branch-

Schema.

Referential Integrity in SQL: Foreign Keys

  • Foreign Keys are specified as part of the SQL ‘create table’ statement by using the ‘foreign key’ clause.
  • By default, a foreign key references the primary key attributes of the referenced table.

Foreign Key Declaration

• EX1:

create table account

( account-number char(10), branch –name char(15), balance integer, primary key (account-number), foreign key (branch-name) references branch, check ( balance >= 0))

Delete Cascade

  • In a delete cascade,

anything that has references to the deleted item is also deleted.

Update Cascade

  • In an update cascade,

when the updated item results in a violation of referential integrity, the system will update accordingly to fix the problem.

Assertions

  • An assertion is a predicate expressing a condition that we wish the database to always satisfy.
  • Domain constraints and referential integrity constraints are special forms of assertions.
  • But there are many constraints we cannot express by using only these special forms.
  • EX1: The sum of all loan amounts for each branch must be less than the sum of all account balances at the branch.

Creating an Assertion

  • EX1:

create assertion sum-constraint check

(not exists (select * from branch where (select sum (amount) from loan where loan.branch-name = branch.branch-name )

= (select sum (balance) from account where account.branch-name = branch.branch-name )))

Triggers

  • A trigger is a statement that the system executes automatically as a side effect of a modification to the database.
  • To design a trigger we must meet two requirements:
      1. Specify when a trigger is to be executed. This is broken up into an event that causes the trigger to be checked and a condition that must be satisfied for trigger execution to proceed.
      1. Specify the actions to be taken when the trigger executes.
  • This is referred to as the event-condition-action model of triggers

Triggers

  • The database stores triggers just as if they

were regular data.

  • This way they are persistent and are accessible

to all database operations.

  • Once a trigger is entered into the database,

the database system takes on the

responsibility of executing it whenever the

event occurs and the condition is satisfied.

Security!

  • The information in your

database is important.

  • Therefore, you need a

way to protect it against unauthorized access, malicious destruction or alteration, and accidental introduction of data inconsistency.

Database Security

  • Database Security refers to protection from

malicious access.

  • Absolute protection is impossible
  • Therefore, make the cost to the perpetrator so

high it will deter most attempts.