Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
DB Interface Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWDBForeignKey

Module:  DB Interface Module   Group:  Database Classes


RWDBForeignKey RWCollectable

Local Index

Members

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'
defaultify = 'D' };

Public Constructors

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

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; 
RWCString 
constraintName() const;
void
constraintName(const RWCString& newName);
void
deleteConstraint(Constraint newConstraint);
Constraint 
deleteConstraint() const;
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; 
bool
isEmpty() const;
bool
isValid() const;
RWDBSchema& 
referenceKey();
void
referenceKey(const RWDBSchema& schema);
RWCString 
referenceName() const;
void
setErrorHandler(RWDBStatus::ErrorHandler handler);
RWDBStatus
status() const;
Constraint 
updateConstraint() const;
void 
updateConstraint(Constraint newConstraint);


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.