Looking in [`/xml/schema/Pledge`](https://github.com/civicrm/civicrm-core/blob/master/xml/schema/Pledge)
as an example we see 4 files:
-`files.xml`
-`Pledge.xml`
-`PledgePayment.xml`
-`PledgeBlock.xml`
The `files.xml` is just a list of the other files. Each of the other files describes a
table in the database, defining both table-leve and field-level metadata
including foreign keys and indexes:
```
<table>
<base>CRM/SMS</base>
<class>History</class>
<name>civicrm_sms_history</name>
<comment>SMS History can be linked to any object in the application.</comment>
<add>1.4</add>
<drop>2.0</drop>
... etc
```
An example of a field definition is:
```
<field>
<name>amount</name>
<uniqueName>pledge_amount</uniqueName>
<title>Total Pledged</title>
<type>decimal</type>
<required>true</required>
<import>true</import>
<comment>Total pledged amount.</comment>
<add>2.1</add>
</field>
```
<!-- fixme:
The field 'amount' in the table 'pledge' has a unique name to distinquish it from fields in other tables (e.g. contribute) with the same field. This isn't consistent in all tables and I am trying to find out the reason / rules for this. Also, I presume 'import' means the field is exposed for .... imports?.-->
We can see that the above 'pledge_amount' field was added in CiviCRM v2.1.
Occassionally tables are dropped from the core schema so will not have associated DAOs.
Tags acceptable within `<table>` / `<field>` / `<pseudoconstant>`
| Tag | Contains | Example | Acceptable<br>Instances | Purpose |
| -- | -- | -- | -- | -- |
| `<table>` | text | `civicrm_campaign` | 0 or 1 | *Not yet documented* |
| `<optionGroupName>` | text | `campaign_type` | 0 or 1 | *Not yet documented* |
| `<keyColumn>` | text | `id` | 0 or 1 | *Not yet documented* |
| `<labelColumn>` | text | `full_name` | 0 or 1 | *Not yet documented* |
| `<nameColumn>` | text | `iso_code` | 0 or 1 | *Not yet documented* |
| `<condition>` | SQL | `parent_id IS NULL` | 0 or 1 | *Not yet documented* |
| `<callback>` | function reference | `CRM_Core_SelectValues::eventDate` | 0 or 1 | *Not yet documented* |
## `<table>` / `<index>` {:#table-index}
Tags acceptable within `<table>` / `<index>`
| Tag | Contains | Example | Acceptable<br>Instances | Purpose |
| -- | -- | -- | -- | -- |
| `<name>` | text | | 1 | Follows the pattern `index_fieldname_anotherfieldname` |
| `<fieldName>` | text | | 1+ | The name of the field to use for this index |
| `<unique>` | `true`/`false` | | 0 or 1 | When `true`, the values in this field (or combination of fields) must be unique across all rows of the table. |
!!! note
Some older `<name>` values are prefixed with `UI_`. You don't need to do this when adding a new index.
!!! tip
You can use multiple `<fieldName>` tags to produce a single index on multiple fields.
| Tag | Contains | Example | Acceptable<br>Instances | Purpose |
| -- | -- | -- | -- | -- |
| `<name>` | text | `contact_id` | 1 | The name of the field in *this* table which stores the value of the field in the *referenced* table |
| `<table>` | text | `civicrm_contact` | 1 | The name of the referenced table, including the table prefix |
| `<key>` | text | `id` | 1 | The name of the field in *referenced* table to which we're pointing (almost always `id`) |
| `<onDelete>` | text | | 0 or 1 | Specifies what to do with *this* entity when the *referenced* entity is deleted. *The behavior when this tag is omitted is not yet documented.* |
Acceptable values for `<onDelete>`:
*`SET NULL` - set the value of the field in this table to `NULL` when the referenced entity is deleted
*`CASCADE` - delete this entity when the referenced entity is deleted
*`RESTRICT` - don't allow the referenced entity to be deleted unless this entity is first deleted
Tags acceptable within `<table>` / `<dynamicForeignKey>`
A dynamic foreign key can reference different tables depending on the value of a field in *this* table. For example, the `Note` entity can store notes which are associated with `Contact`s and also notes which are associated with `Contribution`s and uses a dynamic foreign key to do so.
| Tag | Contains | Example | Acceptable<br>Instances | Purpose |
| -- | -- | -- | -- | -- |
| `<idColumn>` | text | `entity_id` | 1 | The name of the field in *this* table which stores the value of the primary key in the *referenced* table |
| `<typeColumn>` | text | `entity_table` | 1 | The name of the field in *this* table which stores the table name of the *referenced* table |
## Tags acceptable pretty much anywhere
| Tag | Contains | Example | Acceptable<br>Instances | Purpose |
| -- | -- | -- | -- | -- |
| `<add>` | text | `2.2` | 0 or 1 | The CiviCRM version when this schema setting was added
| `<change>` | text | `3.4` | 0 or 1 | The CiviCRM version when this schema setting was changed
| `<modify>` | text | `3.4` | 0 or 1 | *This appears to be an alias of `<change>` but perhaps is not a valid tag*
| `<drop>` | text | `4.1` | 0 or 1 | The CiviCRM version when this schema setting was removed e.g.