Introduction
The Attributes Database allows applications to upload and retrieve
custom data for NMPDR data objects. It uses the ERDB database system (which
is also used by the
SproutDatabase and the
SaplingDatabase) to
store the attributes. Attributes differ from conventional data in that they
are unstructured: new attributes can be added without modifying the database
design. A single attribute database services the entire NMPDR complex.
Attributes are organized by
attribute key. Attribute values are
assigned to
objects. In the real world, objects have types and IDs;
however, to the attribute database only the ID matters. In general, it
is possible to determine the object type from the format of the ID, but
it doesn't matter to the database.
The actual attribute values are stored as a relationship between the attribute
keys and the objects. There can be multiple values for a single key/object pair.
Entities
AttributeGroup
A group is a named set of attribute keys. An attribute key can belong to many groups or none at all.
Groups provide a useful mechanism for classifying certain types of attribute keys. An attribute key's group membership is updated using a table of checkboxes in the attribute web interface. The interface also allows new groups to be created. There is a group for attributes that are only used for
ProteinEncodingGroups? and another for attributes that require NMPDR support. Groups can also be used to specify attribute key white lists for individual applications.
- AttributeKey IsInGroup AttributeGroup (many-to-many)
AttributeGroup Table
| Field |
Type |
Default |
Description |
| id |
name-string |
n/a |
Unique identifier for this AttributeGroup. |
| Index |
Unique |
Fields |
Notes |
| idx0 |
yes |
id |
Primary index for AttributeGroup. |
AttributeKey
An attribute key describes named values attached to a particular type of object. Each instance of this entity contains the attribute's description and its name. An attribute key name must consist of letters, numbers, periods, underscores, and/or hyphens.
AttributeKey Table
| Field |
Type |
Default |
Description |
| id |
name-string |
n/a |
Unique identifier for this AttributeKey. |
| relationship-name |
name-string |
n/a |
Name of the relationship containing the attribute data. This relationship must look exactly like HasValueFor. The only difference is the table name. |
| description |
text |
n/a |
Text describing the attribute. This should explain what the attribute means and what kinds of values are appropriate. |
| Index |
Unique |
Fields |
Notes |
| idx0 |
yes |
id |
Primary index for AttributeKey. |
TargetObject
An object represents a keyed thing to which an attribute can be assigned. In order to improve performance, this table has no data in it. It is simply required by the semantics of the database.
TargetObject Table
| Field |
Type |
Default |
Description |
| id |
string |
n/a |
Unique identifier for this TargetObject. |
| Index |
Unique |
Fields |
Notes |
| idx0 |
yes |
id |
Primary index for TargetObject. |
Relationships
HasValueFor
- Each AttributeKey relates to multiple TargetObjects.
- Each TargetObject relates to multiple AttributeKeys.
This relationship connects an attribute key to its objects. It contains the attribute values, and is therefore the primary data repository for the database.
HasValueFor Table
| Field |
Type |
Default |
Description |
| from-link |
name-string |
n/a |
id of the source AttributeKey. |
| to-link |
string |
n/a |
id of the target TargetObject. |
| subkey |
string |
n/a |
Some attribute keys are split into two parts. The real key is controlled and must correspond to a key in the AttributeKey table. The second part of the key resides in this field. When the attribute value is presented to the user, the two parts of the key are joined together around the splitter value. |
| value |
text |
n/a |
This is the actual attribute value. Note that a single key/object pair may in fact have many values, and therefore many entries in this table. |
| Index |
Unique |
Fields |
Notes |
| idx0 |
|
value |
This index allows searching for an attribute value by its prefix. |
| idx1 |
|
from-link, value |
This index allows searching for values within keys. |
| idx2 |
|
from-link, to-link |
This index sorts all the values for a single attribute key by the target object ID. |
| idxFrom |
|
from-link, subkey |
This index sorts all the values for a single attribute key by the subkey value. |
| idxTo |
|
to-link, from-link, subkey |
This index sorts all the values for an object by attribute key and the subkey. |
IsEvidencedBy
- Each AttributeKey relates to multiple TargetObjects.
- Each TargetObject relates to multiple AttributeKeys.
This relationship connects a feature (target object) to its evidence attributes.
This table exists to separate evidence codes from other attributes for performance reasons. Evidence codes are built from scratch several times a week. Erasing an entire table is faster than erasing individual rows, so putting the evidence codes in their own private table provides significant benefits.
IsEvidencedBy Table
| Field |
Type |
Default |
Description |
| from-link |
name-string |
n/a |
id of the source AttributeKey. |
| to-link |
string |
n/a |
id of the target TargetObject. |
| subkey |
string |
n/a |
Some attribute keys are split into two parts. The real key is controlled and must correspond to a key in the AttributeKey table. The second part of the key resides in this field. When the attribute value is presented to the user, the two parts of the key are joined together around the splitter value. |
| value |
text |
n/a |
This is the actual attribute value. Note that a single key/object pair may in fact have many values, and therefore many entries in this table. |
| Index |
Unique |
Fields |
Notes |
| idx0 |
|
value |
This index allows searching for an attribute value by its prefix. |
| idx1 |
|
from-link, value |
This index allows searching for values within keys. |
| idx2 |
|
from-link, to-link |
This index sorts all the values for a single attribute key by the target object ID. |
| idxFrom |
|
from-link, subkey |
This index sorts all the values for a single attribute key by the subkey value. |
| idxTo |
|
to-link, from-link, subkey |
This index sorts all the values for an object by attribute key and the subkey. |
IsInGroup
- Each AttributeKey relates to multiple AttributeGroups.
- Each AttributeGroup relates to multiple AttributeKeys.
This relationship connects an attribute key to the groups of which it is a member.
IsInGroup Table
| Field |
Type |
Default |
Description |
| from-link |
name-string |
n/a |
id of the source AttributeKey. |
| to-link |
name-string |
n/a |
id of the target AttributeGroup. |
| Index |
Unique |
Fields |
Notes |
| idxFrom |
|
from-link |
|
| idxTo |
|
to-link |
|