120 likes | 234 Views
INTEGRITY. Enforcing integrity in Oracle. Oracle Tables. mrobbert. owner. owner. granted access. Correct data types? Within ranges Any data integrity issues?. Is the data correct?. Is the data consistent?. Is the data consistent between tables? Are the same values equivalent
E N D
INTEGRITY Enforcing integrity in Oracle
Oracle Tables mrobbert owner owner granted access
Correct data types?Within rangesAny data integrity issues? Is the data correct?
Is the data consistent? • Is the data consistent between tables? • Are the same values equivalent • Do foreign keys reference existent primary keys • Has logical consistency been maintained?
How do we maintain correct, consistent data ? • Data Integrity Rules • Referential Integrity Rules • Business Rules
Where do we place the constraints? • Base Tables • Constraints which always apply • Will always be enforced by DBMS • Views • Structure to meet needs • Only enforced when data accessed through view • Front end tool • more constraints avaiable • easier to fomrulate • only enforced if tool is used • lack of centralized control
Base Tables • CREATE TABLE Command • makes base tables • base tables is data structure stored on DASD • All columns must have unique name • Primary key not always required syntactically but needed to establish relationships • SQL verifies • syntax • availability of tablespace • uniqueness of name • creator has proper authorization
VIEWS • Virtual Table - Logical representation of another table or combination of tables. • CREATE VIEW viewname AS (SELECT ...) • Usage • provide security • hide data complexity • reduce syntactic complexity • present different perspective
Operations on Views • Query • Standard select statement • Insert • Delete • SOME views may be used for updating • single table with view containing primary key • all not null fields included in view • views created from joining multiple tables usually do not permit updates
SQL DDL • CREATE SEQUENCE • sequential values • CREATE SEQUENCE seqname INCREMENT BY 1 START WITH 1000 • INSERT INTO tablename VALUES (..., seqname.NEXTVAL,...) • DROP SEQUENCE, DROP INDEX, DROP VIEW
Index • performance enhancer • CREATE INDEX indexnameON tablename (column) • Single or multiple indexes on a table through the selection of one or many columns containing unique data values. • Concatenation of columns to assure uniqueness
Index con’t • Indexes automatically maintained and used by system • Trade off - access time vs update time • Unique index • CREATE UNIQUE INDEX indexnameON tablename(attribute)