Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

RWDBForeignKey


RWDBForeignKey RWCollectable

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <rw/db/forkey.h>

RWDBForeignKey fk;

Description

RWDBForeignKey is used to represent foreign keys in a database. They are used when building up an RWDBSchema in preparation for an RWDBDatabase::createTable() call. They are also used as elements of lists that are returned from RWDBTable::foreignKeys() and RWDBTable::referedToBy(). RWDBForeignKey has much the same interface and semantics as RWDBSchema.

RWDBForeignKey is designed around the Interface/Implementation paradigm. An RWDBForeignKey instance is an interface to a reference-counted implementation; copy constructors and assignment operators produce additional references to a shared implementation. An RWDBForeignKey implementation is a base class from which a family of database-specific foreign key implementations is derived.

Example 1

In this example two tables are created, a Professor table with pid as the primary key and a Course table with profid as a foreign key into the Professor table.

Example 2

This next example queries the Course table for its foreign key into the Professor table. It assumes the tables have been set up according to the example above.

Related Classes

See also: RWDBDatabase, RWDBTable, RWDBForeignKeyList, and RWDBSchema.

Public Enum

enum Constraint { 
 cascade = 'C', 
 restrict='R', 
 nullify = 'N' 
};

Public Constructors

RWDBForeignKey();
RWDBForeignKey(const RWCString& refName = "", 
               Constraint updateConstraint=restrict,
               Constraint deleteConstraint=restrict); 
RWDBForeignKey(const RWDBForeignKey& fk);

Public Member Operators

RWDBForeignKey&
operator=(const RWDBForeignKey& fk);
RWDBColumn
operator[](size_t index) const;
RWDBColumn
operator[](const RWCString& name) const;

Public Member Functions

RWDBColumn
appendColumn(const RWDBColumn& col);
RWCString 
asString(const RWDBPhraseBook& phraseBook) const;
RWDBColumn
column(size_t index) const;
RWDBColumn
column(const RWCString& name) const;
RWDBColumn
column(const RWCString& name, 
       RWCString::caseCompare caseCompare) const; 
Constraint 
deleteConstraint();
size_t
entries() const;
RWDBStatus::ErrorHandler
errorHandler() const;
size_t
index(const RWCString& name) const;
size_t
index(const RWCString& name, 
      RWCString::caseCompare caseCompare) const; 
size_t
index(const RWDBColumn& column) const; 
RWBoolean
isEmpty() const;
RWBoolean
isValid() const;
RWCString 
referenceName();
void
setErrorHandler(RWDBStatus::ErrorHandler handler);
RWDBStatus
status() const;
Constraint 
updateConstraint();


Previous fileTop of DocumentContentsIndexNext file

©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.