kexi
KexiDB::IndexSchema Class Reference
#include <indexschema.h>
Inheritance diagram for KexiDB::IndexSchema:

Detailed Description
Provides information about database index that can be created for a database table.IndexSchema object stores information about table fields that defines this index and additional properties like: whether index is unique or primary key (requires unique). Single-field index can be also auto generated.
Definition at line 43 of file indexschema.h.
Constructor & Destructor Documentation
IndexSchema::IndexSchema | ( | TableSchema * | tableSchema | ) |
Constructs empty index schema object that is assigned to table, and will be owned by this table. Any fields added with addField() won't be owned by index, but by its table. Do not forget to add these fields to table, because adding these to IndexSchema is not enough.
Definition at line 32 of file indexschema.cpp.
IndexSchema::IndexSchema | ( | const IndexSchema & | idx, | |
TableSchema & | parentTable | |||
) |
Copy constructor. Copies all attributes from index idx, and fields assigned with it but the fields are taken (by name) from parentTable, not from idx itself, so it's possible to copy of index for a copy of table.
To copy an index within the same table it's enough to call:
new IndexSchema(idx, *idx.table());
- Todo:
- All relationships should be also copied
Definition at line 44 of file indexschema.cpp.
IndexSchema::~IndexSchema | ( | ) | [virtual] |
Destroys the index. Field objects are not deleted. All Relationship objects listed in masterRelationships() list are destroyed (these are also detached from detail-side indices before destruction). Relationship objects listed in detailsRelationships() are not touched.
Definition at line 75 of file indexschema.cpp.
Member Function Documentation
Adds field at the end of field list. Field will not be owned by index. Field must belong to a table the index is bulit on, otherwise field couldn't be added.
Reimplemented from KexiDB::FieldList.
Definition at line 91 of file indexschema.cpp.
KexiDB::TableSchema * IndexSchema::table | ( | ) | const |
Relationship::List* KexiDB::IndexSchema::masterRelationships | ( | ) | [inline] |
- Returns:
- list of relationships from the table (of this index), i.e. any such relationship in which this table is at 'master' side. See Relationship class documentation for more information. All objects listed here will be automatically destroyed on this IndexSchema object destruction.
Definition at line 89 of file indexschema.h.
Relationship::List* KexiDB::IndexSchema::detailsRelationships | ( | ) | [inline] |
- Returns:
- list of relationships to the table (of this index), i.e. any such relationship in which this table is at 'details' side. See Relationship class documentation for more information.
Definition at line 94 of file indexschema.h.
void IndexSchema::attachRelationship | ( | Relationship * | rel | ) |
Attaches relationship definition rel to this IndexSchema object. If rel relationship has this IndexSchema defined at the master-side, rel is added to the list of master relationships (available with masterRelationships()). If rel relationship has this IndexSchema defined at the details-side, rel is added to the list of details relationships (available with detailsRelationships()). For the former case, attached rel object is now owned by this IndexSchema object.
Note: call detachRelationship() for IndexSchema object that rel was previously attached to, if any.
Definition at line 164 of file indexschema.cpp.
void IndexSchema::detachRelationship | ( | Relationship * | rel | ) |
Detaches relationship definition rel for this IndexSchema object from the list of master relationships (available with masterRelationships()), or from details relationships list, depending for which side of the relationship is this IndexSchem object assigned.
Note: If rel was detached from masterRelationships() list, this object now has no parent, so you need to attach it to somewhere or destruct it.
Definition at line 192 of file indexschema.cpp.
bool IndexSchema::isAutoGenerated | ( | ) | const |
- Returns:
- true if index is auto-generated. Auto-generated index is one-field index that was automatically generated for CREATE TABLE statement when the field has UNIQUE or PRIMARY KEY constraint enabled.
This flag is handled internally by TableSchema. It can be usable for GUI application if we do not want display implicity/auto generated indices on the indices list or we if want to show these indices to the user in a special way.
Definition at line 109 of file indexschema.cpp.
bool IndexSchema::isPrimaryKey | ( | ) | const |
- Returns:
- true if this index is primary key of its table. This can be one or multifield.
Definition at line 119 of file indexschema.cpp.
void IndexSchema::setPrimaryKey | ( | bool | set | ) |
Sets PRIMARY KEY flag.
- See also:
- isPrimary(). Note: Setting PRIMARY KEY on (true), UNIQUE flag will be also implicity set.
Definition at line 124 of file indexschema.cpp.
bool IndexSchema::isUnique | ( | ) | const |
- Returns:
- true if this is unique index. This can be one or multifield.
Definition at line 131 of file indexschema.cpp.
void IndexSchema::setUnique | ( | bool | set | ) |
Sets UNIQUE flag.
- See also:
- isUnique(). Note: Setting UNIQUE off (false), PRIMARY KEY flag will be also implicity set off, because this UNIQUE is the requirement for PRIMARY KEYS.
Definition at line 136 of file indexschema.cpp.
QString IndexSchema::debugString | ( | ) | [virtual] |
- Returns:
- String for debugging purposes.
Reimplemented from KexiDB::FieldList.
Definition at line 154 of file indexschema.cpp.
void IndexSchema::setAutoGenerated | ( | bool | set | ) | [protected] |
Sets auto-generated flag. This method should be called only from TableSchema code
- See also:
- isAutoGenerated().
Definition at line 114 of file indexschema.cpp.
void IndexSchema::setForeignKey | ( | bool | set | ) | [protected] |
If set is true, declares that the index defines a foreign key, created implicity for Relationship object. Setting this to true, implies clearing 'primary key', 'unique' and 'auto generated' flags. If this index contains just single field, it's 'foreign field' flag will be set to true as well.
Definition at line 143 of file indexschema.cpp.
void IndexSchema::attachRelationship | ( | Relationship * | rel, | |
bool | ownedByMaster | |||
) | [protected] |
Internal version of attachRelationship(). If ownedByMaster is true, attached rel object will be owned by this index.
Definition at line 169 of file indexschema.cpp.
Member Data Documentation
table on that index is built
a list of master relationships for the table (of this index), this index is a master key for these relationships and therefore - owner of these
Definition at line 188 of file indexschema.h.
Relationship::List KexiDB::IndexSchema::m_master_rels [protected] |
a list of master relationships that are not owned by this schema
Definition at line 191 of file indexschema.h.
a list of relationships to table (of this index)
Definition at line 194 of file indexschema.h.
The documentation for this class was generated from the following files: