See Also Example Methods Properties
A CdbRelation object represents a relationship between fields in tables or queries (Microsoft Jet databases only).
Remarks
You can use the CdbRelation object to create new relationships and examine existing relationships in your database.
Using a CdbRelation object and its properties, you can:
If you make changes that violate the relationships established for the database, a trappable error occurs. If you request cascading update or cascading delete operations, the Microsoft Jet database engine also modifies the primary or foreign key tables to enforce the relationships you establish.
For example, the Northwind database contains a relationship between an Orders table and a Customers table. The CustomerID field of the Customers table is the primary key, and the CustomerID field of the Orders table is the foreign key. For Microsoft Jet to accept a new record in the Orders table, it searches the Customers table for a match on the CustomerID field of the Orders table. If Microsoft Jet doesn't find a match, it doesn't accept the new record and a trappable error occurs.
When you enforce referential integrity, a unique index must already exist for the key field of the referenced table. The Microsoft Jet database engine automatically creates an index with the Foreign property set to act as the foreign key in the referencing table.
To create a new CdbRelation object, use the CreateRelation method. To refer to a CdbRelation object in a collection by its ordinal number or by its Name property setting, use either of the following syntax forms:
Relations[0]
Relations["name"]
CdbRelation Constructor Syntax
Use any one of the following three constructors. The qualifier 'CONSTRUCTOR' in the syntax models is provided to help readability. It has no syntactic value.
CONSTRUCTORCdbRelation(VOID);
This constructor creates an instance of the class. There are no parameters.
CONSTRUCTORCdbRelation(const CdbRelation &);
Type | Description |
const CdbRelation & | Reference to an object. |
This constructor creates a copy of the object referenced in the parameter.
CONSTRUCTORCdbRelation(DAORelation *prl,
BOOL bAddRef = FALSE);
Type | Argument | Description |
DAORelation * | prl | A DAO Automation interface pointer corresponding to this DAO class. |
BOOL | bAddRef
=FALSE |
Optional. A Boolean. If TRUE, the DAO Automation interface AddRef function is called. |
DAO functionality is presented through pointers to DAO Automation interfaces. This constructor makes a DAO interface available in the form of a DAO class object that provides additional functionality.
This constructor is not required for typical use. It is provided to enable you to easily create a DAO class object if you have access to the corresponding DAO interface.
When the destructor for the DAO object is invoked, the underlying Automation interface's Release member is called. If Release decrements the interface's reference count to zero, the pointer to the Automation interface can be deleted. If you don't want this to happen (for example, because you want to discard the DAO object, but continue using the Automation interface), specify TRUE for the second parameter. The underlying Automation interface's AddRef member is called, which counterbalances the eventual call to Release.