Data Integrity
- integrity constraints enforce the business rules is a schema object that is created and dropped using SQL, associated with a database and prevent the entry of invalid information into tables, must always be true or must always be false- Enforcing business rules with triggered stored database procedures
- Using stored procedures to completely control access to data
- Enforcing business rules in the code of a database application
- Using Oracle Database integrity constraints, which are rules defined at the column or object level that restrict values in the database
1. Declarative ease
- no additional programming is required when you define or alter a table
- SQL statements are easy to write and eliminate programming errors.
- defined for tables and are stored in the data dictionary
- all applications must adhere to the same integrity constraints, applications need not change
- applications can use metadata in the data dictionary to immediately inform users of violations
- disable & enable integrity constraints temporarily to avoid performance overhead when loading large amounts of data
1. part of the definition of a column or attribute is called an inline2. part of the table definition is called an out-of-line specification- key is the column or set of columns included in the definition of certain types of integrity constraints
3. create after table creation using alter table called after-creation
- Types of Constraints
1. NOT NULL, Allows or disallows inserts or updates of rows containing a null in a specified columnA primary key can be natural or a surrogate.
2. Unique key, Prohibits multiple rows from having the same value in the same column or combination of columns but allows some values to be null.
3. Primary key, It prohibits multiple rows from having the same value in the same column or combination of columns and prohibits values from being null.
1. natural key is a meaningful identifier made of existing attributes in a table. For example, a natural key could be a postal code in a lookup table.- implementation of the primary key constraint guarantees
2. surrogate key is a system-generated incrementing identifier that ensures uniqueness within a table. Typically, surrogate keys are generated by a sequence.
a. No duplicate values
b. Not allow nulls
c. creates a unique index and a NOT NULL constraint
d. when you create a primary key with a Deferrable Constraint , the generated index is not unique
4. Foreign key, Designates a column as the foreign key and establishes a relationship between the foreign key and a primary or unique key, called the referenced key. Oracle Database can enforce the relationship between the two tables through a foreign key constraint, also called referential integrity constraint.
- Referential Integrity Constraint Terms
5. Check, Requires a database value to obey a specified condition.
6. REF, Dictates types of data manipulation allowed on values in a REF column and how these actions affect dependent values
4. Foreign key, Designates a column as the foreign key and establishes a relationship between the foreign key and a primary or unique key, called the referenced key. Oracle Database can enforce the relationship between the two tables through a foreign key constraint, also called referential integrity constraint.
- Referential Integrity Constraint Terms
- Foreign key > department_id column in employees is a foreign key
- Referenced key > department_id column in departments is the referenced key
- Dependent or child table > employees table is a child of departments
- Referenced or parent table > departments table is a parent of employees
5. Check, Requires a database value to obey a specified condition.
6. REF, Dictates types of data manipulation allowed on values in a REF column and how these actions affect dependent values
No comments:
Post a Comment