Generating Views

Meta Data Services Programming

Meta Data Services Programming

Generating Views

A repository database stores classes, properties, and relationships in a table structure that does not reflect the composition of an information model. While this arrangement is optimal for the repository engine, it can be difficult to work with if you want to query the database.

To simplify querying, you can generate SQL views of your repository database that correspond to an information model. An SQL view provides a mechanism for gathering elements from the repository tables and assembling them into a virtual table that resembles a specific class, interface, or relationship in your information model. Generated views simplify database queries by eliminating the need to understand the underlying structure of a repository database. In addition, views allow you to represent any relationship, including a many-to-many relationship, as a junction table view, which is something you cannot specify in an information model. Views also provide a way to represent each many-to-one relationship as a foreign key.

View Types

You can define three kinds of SQL views for each class, interface, and relationship. For more information about each view type, see Defining Views in an Information Model and Kinds of SQL Views.

Performance varies for each kind of view. For more information about how to improve view performance, see View Hints.

How to Generate Views

View generation requires Microsoft® SQL Server™ 2000 and repository engine 3.0. The 3.0 repository database format provides storage for the view definitions you add to an information model. For more information about upgrading to a 3.0 database, see Upgrading and Migrating a Repository Database.

View generation is performed by the repository engine in response to flags that you set in the information model. If, while creating a model, the repository engine finds one of these flags set to True, it generates an SQL view from your view definitions.

By default, view generation flags are set to False. To generate a SQL view after an information model is installed, you can write code that sets the flags to True. You can also set the flags in an information model, then reinstall it.

The repository engine synchronizes your generated views with subsequent changes you make to an information model (for example, adding an interface to a class or adding an interface implication). As long as view generation flags remain set to True, synchronization occurs automatically.

Storing SQL Views

View definitions are stored in the repository SQL tables. Class view definitions are stored in the RTblClassDefs table. Interface view definitions are stored in the RTblIfaceDefs table. Junction table view definitions are stored in the RTblRelshipDefs table.

Generated views are stored by your DBMS in the same catalog and schema that contains your information model.

See Also

Repository Databases

RTblClassDefs SQL Tables

RTblIfaceDefs SQL Tables

RTblRelshipDefs SQL Tables