MySQL NDB Cluster API Developer Guide
This section provides information about the
ForeignKey class, which models a foreign key on
an NDB table.
None.
The following table lists the public methods of the
ForeignKey class and the purpose or use
of each method:
Table 2.20 ForeignKey class methods and descriptions
| Name | Description |
|---|---|
ForeignKey() |
Class constructor |
~ForeignKey() |
Class destructor |
getName() |
Get the foreign key's name |
getParentTable() |
Get the foreign key's parent table |
getChildTable() |
Get the foreign key's child table |
getParentColumnCount() |
Get the number of columns in the parent table |
getChildColumnCount() |
Get the number of columns in the child table |
getParentColumnNo() |
Get the column number in the parent table |
getChildColumnNo() |
Get the column number in the child table |
getParentIndex() |
Returns 0 if key points to parent table's primary key |
getChildIndex() |
Returns 0 if child references resolved using child table's primary key |
getOnUpdateAction() |
Get the foreign's key update action
(FkAction) |
getOnDeleteAction() |
Get the foreign key's delete action
(FkAction) |
setName() |
Set the foreign key's name |
setParent() |
Set the foreign key's parent table |
setChild() |
Set a foreign key's child table |
setOnUpdateAction() |
Set the foreign's key update action
(FkAction) |
setOnDeleteAction() |
Set the foreign key's delete action
(FkAction) |
getObjectStatus() |
Get the object status |
getObjectId() |
Get the object ID |
getObjectVersion() |
Get the object version |
The ForeignKey class has one public type,
the FkAction
type.
Create either an entirely new foreign key reference, or a copy of an existing one.
New instance:
ForeignKey
(
void
)
Copy constructor:
ForeignKey
(
const ForeignKey&
)
For a new instance: None.
For the copy constructor: A reference to an existing
instance of ForeignKey.
A new instance of ForeignKey.
This section provides information about
FkAction, which is an enumeration modelling a
reference action for a foreign key when an update or delete
operation is performed on the parent table.
Possible values are shown, along with the corresponding reference action, in the following table:
Table 2.21 ForeignKey::FkAction data type values and descriptions
| Name | Description |
|---|---|
NoAction |
NO ACTION: Deferred check. |
Restrict |
RESTRICT: Reject operation on parent table. |
Cascade |
CASCADE: Perform operation on row from parent table;
perform same operation on matching rows in child
table. |
SetNull |
SET NULL: Perform operation on row from parent table;
set any matching foreign key columns in child table to
NULL. |
SetDefault |
SET DEFAULT: Currently not supported in NDB Cluster. |
See also FOREIGN KEY Constraints, in the MySQL Manual.
Retrieve the name of the ForeignKey
instance for which the method is invoked.
const char* getName
(
void
) const
None.
The name of the ForeignKey.
Retrieve the parent table of the
ForeignKey instance for which the method
is invoked.
const char* getParentTable
(
void
) const
None.
A pointer to the parent table of the
ForeignKey.
Retrieve the child table of the
ForeignKey instance for which the method
is invoked.
const char* getChildTable
(
void
) const
None.
A pointer to the child table of this
ForeignKey.
Retrieve the number of columns in the parent table of this
ForeignKey.
unsigned getParentColumnCount
(
void
) const
None.
The number of columns in the parent table.
Retrieve the number of columns in the child table of this
ForeignKey.
unsigned getChildColumnCount
(
void
) const
None.
The number of columns in the child table.
Returns 0 if the child table refers to the parent table's primary key.
const char* getParentIndex
(
void
) const
None.
See description.
Return 0 if child references are resolved using the child table's primary key.
const char* getChildIndex
(
void
) const
None.
See description.
This method gets the sequence number of a foreign key column
in the parent table for a given index. See the documentation
for Column::getColumnNo(),
for information about handling columns in the NDB API.
int getParentColumnNo
(
unsigned no
) const
None.
The sequence number of the column.
This method gets the sequence number of a foreign key column
in the child table for a given index. See the documentation
for Column::getColumnNo()
for information about handling columns in the NDB API.
int getChildColumnNo
(
unsigned no
) const
None.
The sequence number of the column.
Get the foreign key's ON UPDATE
action. This is a
ForeignKey::FkAction and
has one of the values NoAction,
Restrict, Cascade, or
SetNull.
FkAction getOnUpdateAction
(
void
) const
None.
The sequence number of the column.
Get the foreign key's ON DELETE
action. This is a
ForeignKey::FkAction and
has one of the values NoAction,
Restrict, Cascade, or
SetNull.
FkAction getOnDeleteAction
(
void
) const
None.
The sequence number of the column.
Set the name of the ForeignKey instance
for which the method is invoked.
void setName
(
const char*
)
The name of the ForeignKey.
None.
Set the parent table of a ForeignKey,
given a reference to the table, and optionally, an index to
use as the foreign key.
void setParent
(
const Table&,
const Index* index = 0,
const Column* cols[] = 0
)
A reference to a Table
(required). Optionally, an index using the indicated column
or columns.
None.
Set the child table of a ForeignKey,
given a reference to the table, and optionally, an index to
use as the foreign key.
void setChild
(
const Table&,
const Index* index = 0,
const Column* cols[] = 0
)
A reference to a Table
(required). Optionally, an index using the indicated column
or columns.
None.
Set the foreign key's ON UPDATE
action.
void setOnUpdateAction
(
FkAction
)
The ON UPDATE action to be performed.
This must be a
ForeignKey::FkAction having
one of the values NoAction,
Restrict, Cascade, or
SetNull.
None
Set the foreign key's ON DELETE
action.
void setOnUpdateAction
(
FkAction
)
The ON UPDATE action to be performed, of
type ForeignKey::FkAction.
Must be one of the values NoAction,
Restrict, Cascade, or
SetNull.
None
Get the object status (see
Object::Status) for this
ForeignKey object.
virtual Object::Status getObjectStatus
(
void
) const
None.
The ForeignKey object's status, as a
value of type
Object::Status. See this
type's documentation for possible values and their
interpretation.
Get the object ID (see
Object::getObjectId()) for this
ForeignKey object.
virtual int getObjectId
(
void
) const
None.
The ForeignKey object's ID, as
returned by
Object::getObjectId().
Get the object version (see
Object::getObjectVersion()) for this
ForeignKey object.
virtual int getObjectVersion
(
void
) const
None.
The ForeignKey object's version
number (an integer), as returned by
Object::getObjectVersion().