• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/77

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

77 Cards in this Set

  • Front
  • Back
What are constraints?
rules or restrictions that guide database inserts, updates and deletions
What is the function of constraints?
to keep invalid or erroneous data out of the database
In what three ways can integrity constraints be enforced?
-Declare an integrity constraint
-Write a database trigger
-Include constraints in an application
What is the biggest advantage and disadvantage to including constraints in an application?
Advantage: flexibility/fine tuning
Disadvantage: outside the db, so modifications made outside of the application are not affected by the constraint
What are three advantages to declaring an integrity constraint to enforce integrity?
-simple to create and maintain
-always enforced
-perform faster because the optimizer handles them efficiently
What are the five types of integrity constraints supported by Oracle 10g?
-PRIMARY KEY
-UNIQUE
-FOREIGN KEY
-NOT NULL
-CHECK
What is a PRIMARY KEY?
a column or set of columns that define a unique identifying value for every row in the table
What two terms can be used to describe a PRIMARY KEY which is made up of multiple columns?
-compound key
-composite key
What are two rules underly the enforcement of the PRIMARY KEY constraint?
-UNIQUE
-NOT NULL
How many primary keys may a table have?
0 or 1
What is referential integrity?
the integrity, or soundness of data, maintained between two values which reference each other (a primary key in one table and foreign key in another table)
What is a UNIQUE key?
similar to PRIMARY KEY in that it enforces unique values, but unlike it in that it allows nulls in its columns (although it ignores them)
May a table have more than one UNIQUE key constraint?
Yes
What is a FOREIGN KEY?
a value in the child table, referencing the PRIMARY KEY of the parent table
What is the purpose of a FOREIGN KEY?
To establish a relationship between two tables, in which one is the parent table and the other is the child
Does the FOREIGN KEY reside in the parent table or the child table?
the child table
What does the FOREIGN KEY constraint require of its column?
that every row in the child table contain either a value that matches a PRIMARY KEY value from the parent table, or contains a NULL value
What is a NOT NULL constraint?
indicates that every row in the table must contain a value in the column on which the constraint is placed
What is a CHECK constraint?
enforces a predefined list of values for a column.
Can a column with a CHECK constraint contain null values?
Yes, unless another constraint restricts it (such as NOT NULL)
What two DDL commands can be used to create an integrity constraint?
CREATE TABLE
ALTER TABLE
Describe defining constraints inline vs out of line
-inline: applies to only one column and appears immediately next to the column
-out of line: applies to one or multiple columns and appears after the full list of columns
What is the only type of constraint that may not be defined out of line?
NOT NULL
What is the only type of constraint that may be defined inline in an ALTER TABLE statement?
NOT NULL
When multiple conditions apply to a column, is it better to write one CHECK constraint to check multiple conditions, or write multiple CHECK constraints to check each condition separately, and why?
Write multiple CHECK constraints separately, giving them specific, useful names. When a constraint is violated, the name of the constraint appears to the user, and may help them correct the data.
Which constraint type must be defined out of line if custom-naming is desired?
FOREIGN KEY
What is a constraint state?
attribute that tells Oracle 10g who to use the constraint when data is added to the table
Name seven constraint state pairs
- ENABLE | DISABLE
- VALIDATE | NOVALIDATE
- INITIALLY IMMEDIATE | INITIALLY DEFERRED
- DEFERRABLE | NOT DEFERRABLE
- RELY | NORELY
- USING INDEX <index> | <storage>
- EXCEPTIONS | EXCEPTIONS INTO <tablename>
Is ENABLE or DISABLE the default constraint state?
ENABLE
What effect does DISABLE have on existing data?
none, except if the constraint is a PRIMARY KEY or UNIQUE key, the associated unique index is dropped
What effect does re-enabling a disabled constraint using the ENABLE keyword have on existing data?
It checks all the rows for compliance, unless you specify ENABLE NOVALIDATE
Is VALIDATE or NOVALIDATE the default constraint state?
VALIDATE
What effect does NOVALIDATE have on existing and new data?
existing data is not checked, but new data must comply with the constraint if it is ENABLEd
If you add several thousand new rows which you know comply with an existing constraint, how might you save time?
Specify DISABLE, load the rows, then specify ENABLE NOVALIDATE to avoid Oracle 10g running through all the rows looking for rows that fail to comply
What is the difference between INITIALLY IMMEDIATE and INITIALLY DEFERRED constraint states and which is the default?
INITIALLY IMMEDIATE means that data is validated against the constraint as soon as the statement is executed. INITIALLY DEFERRED means that data is only validated against the constraint when a COMMIT command is executed.
INITIALLY IMMEDIATE is the default state for Oracle 10g. INITIALLY DEFERRED was not available in prior versions of Oracle.
What is the difference between DEFERRABLE | NOT DEFERRABLE constraint states and which one is the default?
Determines whether or not a constraint is allowed to be changed to a deferred state. NOT DEFERRABLE is the default.
Which constraint state must be specified upon creation and may not use ALTER TABLE to change it? How do you change the constraint state?
DEFERRABLE | NOT DEFERRABLE
To change the constraint state, you must drop the constraint and recreate it.
What is the difference between RELY and NORELY constraint states and which one is default?
RELY tells the optimizer to use disabled constraints, and NORELY to ignore them, when rewriting queries.
NORELY is default
Which constraint state is usually only used for data warehouses using materialized views and query rewrites?
RELY
Which constraints can utilize a constraint state USING INDEX?
PRIMARY KEY
UNIQUE
What are the 2 choices you have for USING INDEX constraint state?
-using a pre-existing index for the constraint
-specifying the storage setting for an index that will be created for the constraint
What must you do or ensure before using the EXCEPTIONS | EXCEPTIONS INTO constraint state?
Create a table for the exceptions, either named EXCEPTIONS or with your own specified name. To do this, run a script in ORACLE_HOME/rdbms/admin, either utlexcpt.sql (supports physical ROWIDs) or utlexpt1.sql (supports universal ROWIDs-such as on index-organized tables)
How can you tell a FOREIGN KEY constraint to delete all related rows when a parent row is deleted, and how can you tell it to keep the related rows but change the FOREIGN KEY column to null?
-ON DELETE CASCADE
-ON DELETE SET NULL
What are the only two constraint-related data dictionary views?
- ALL_CONSTRAINTS
- ALL_CONS_COLUMNS
Is it better to have the index and table in the same tablespace or different tablespaces?
different tablespaces
What type of index stores an entry for a row with all null values in the indexed columns?
bitmap index
Name six types of indexes
-BTree
-Bitmap
-Local partitioned index
-Global partitioned index
-Cluster index
-Domain index
Name two specialized types of BTree indexes
-Reverse key index
-Function-based index
Which index type has an index structure in which data is divided and subdivided based on the index key values?
BTree Index
What is Oracle 10g's default type of index that is used when building tables?
BTree Index
Which index type takes up less storage space, BTree Index or Bitmap Index?
Bitmap Index
What is the starting point to find a value on a binary tree or BTree?
root
In a binary tree structure, a _____ is any point on the tree.
node
In a binary tree structure, a ______ is a node that has more nodes below it.
branch
In a binary tree structure, a _____ is the bottom level and is a node with no nodes below it.
leaf
Know when it is appropriate to use a Bitmap index.
- The indexed columns should have low cardinality. (the number of distinct values in an indexed column should be low compared to the number of rows in a table).
- The table should used primarily for queries, rather than updates.
- The majority of the queries should use AND, OR, NOT, and "equal to" in the WHERE clause referencing the table's indexed columns.
- The majority of the queries include complex conditions in the WHERE clause.
- The table should not have concurrent updates.
- A bitmapped index cannot be a unique index.
- A bitmapped index cannot contain any DESC columns.
What type of index is used on tables in which indexes are created for each individual partition?
Local partitioned index
What specialized type of BTree index contains columns that have been stored in reverse byte order?
Reverse Key Indexes
What is the difference between specifying REVERSE on an index and specifying DESC on an indexed column?
DESC is used for descending order on an indexed column. When using the REVERSE function it essentially spells each name backwards and then alphabetizes the list.
Which specialized type of BTree index substitutes a function or expression for a column?
Function-based Indexes
Which command allows you to make changes to the index?
ALTER INDEX
What allows easy access to database objects across schemas and databases?
Synonyms
What command can modify an index to help when too much unused storage is allocated or to fix incorrect settings for PCTINCREASE, NEXT or other storage settings?
ALTER INDEX ... REBUILD
What clause of the ALTER INDEX command can be used (faster than rebuilding) to consolidate fragmented storage space in the leaf blocks?
COALESCE
What clause of the ALTER INDEX command can be used only on normal indexes and index-reorganized tables to update the physical guesses of the indexed row's location stored in the index?
UPDATE BLOCK REFERENCES
What clause of the ALTER INDEX command can be used to cause the optimizer to ignore the index when determining execution plans?
UNUSABLE
Name and describe two distinct forms of views.
1. Simple view-contains a query on one of more tables, narrowing the focus or visible data window of a specific user to a subset of the rows and/or a subset of the columns.
2. Constraint view-can be used to insert a new row as long as the row would be returned by the query, or the row exists for the view.
Name and describe four common reasons for using views.
1. Security-limiting the subset of data a user can view
2. Simplicity-combining tables that have complex relationships to easy query-writing for other users.
3. Complex joins-such as creating a view with a GROUP BY clause and then joining that summary data with other tables.
4. Materialized views-not as much of a view because the data is actually stored in it. Most commonly used in data warehouses.
What is the advantage of Reverse Key indexing, and where is it useful?
helps prevent locking delays in RAC
What are some advantages of Materialized Views?
-contains a copy of the data
-able to be indexed
How can materialized views be refreshed?
-real time
-on commit
-periodic
What is a more efficient method to acheive the results of using a function-based index and why?
-Use case statements before the if-then-else statements so that the result can be used and the index can still be used as well
-because a function based index creates a physical structure that must also be maintained
Give two tips for what to do when rebuilding indexes?
1. move it to another tablespace
2. change the INITTRANS parameter
When is a check constraint preferable to a lookup table?
when there are fewer choices (about 5) and the column is static
What type of index is useful for a data warehouse but not userful for OLTP because it locks the table to update?
Bitmap index
What is a sequence?
It is like an identity column, but it is not tied to a specific table... it is a separate object.
Is it advisable to cache a sequence and why or why not?
-No, because it would be detrimental if the database crashed because you would lose the unused values in the cache.