Define Constraints on Views (188)

tsinglee發表於2007-11-12

Data warehousing applications recognize multidimensional data in the Oracle
database by identifying Referential Integrity (RI) constraints in the relational schema.
RI constraints represent primary and foreign key relationships among tables. By
querying the Oracle data dictionary, applications can recognize RI constraints and
therefore recognize the multidimensional data in the database. In some environments,
database administrators, for schema complexity or security reasons, define views on
fact and dimension tables. Oracle provides the ability to constrain views. By allowing
constraint definitions between views, database administrators can propagate base
table constraints to the views, thereby allowing applications to recognize
multidimensional data even in a restricted environment.

Only logical constraints, that is, constraints that are declarative and not enforced by
Oracle, can be defined on views. The purpose of these constraints is not to enforce any
business rules but to identify multidimensional data. The following constraints can be
defined on views:
■ Primary key constraint
■ Unique constraint
■ Referential Integrity constraint
Given that view constraints are declarative, DISABLE, NOVALIDATE is the only valid
state for a view constraint. However, the RELY or NORELY state is also allowed,
because constraints on views may be used to enable more sophisticated query
rewrites; a view constraint in the RELY state allows query rewrites to occur when the
rewrite integrity level is set to trusted mode.

Note: Although view constraint definitions are declarative in nature,
operations on views are subject to the integrity constraints defined on
the underlying base tables, and constraints on views can be enforced
through constraints on base tables.

在檢視上定義約束
1. Oracle 還提供了在檢視上定義約束的功能 , 資料庫管理員可以將基表上的約束propagate在檢視上
2. 只有邏輯約束(使用者宣告而非Oracle強制)才能定義在檢視上
3. 主鍵約束 , 唯一鍵約束 , 引用完整性約束可定義在檢視上
4. 定義在檢視上的約束是宣告性質的 , 對於檢視約束來說DISABLE, NOVALIDATE兩種狀態是有效的
RELY or NORELY兩種狀態也是允許的(使用查詢重寫)
5. 當重寫完整性級別(被設為信任模式時 , 將檢視約束設定為 RELY 狀態將允許使用查詢重寫.

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10599713/viewspace-981944/,如需轉載,請註明出處,否則將追究法律責任。

相關文章