Answers.Body: <p>You should use the <strong>API</strong> as the data dictionary. The <strong>API explorer</strong> (available in every installation) provides a convenient interface to browse the data dictionary.</p>
  
  <p>The demo sites each have an API explorer and they are the authoritative public data dictionary for CiviCRM. For example  <a href="http://dmaster.demo.civicrm.org/civicrm/api/explorer" rel="nofollow">http://dmaster.demo.civicrm.org/civicrm/api/explorer</a> (login first with username:demo and password:demo). <a href="https://civicrm.org/sandboxes" rel="nofollow">Other versions are also available.</a>.</p>
  
  <p>The entity select box shows a list of all available entities.  For each entity, the three most important actions from a 'data dictionary' perspective are</p>
  
  <ul>
  <li><strong>getfields</strong> - for the given entity, this action shows available fields </li>
  <li><strong>getactions</strong> - for the given entity, this action shows available actions </li>
  <li><strong>getoptions</strong> - for the given entity <em>and field</em> this action shows available options (only available for multiple choice fields).</li>
  </ul>
  
  <p>Here are some examples of useful API calls:</p>
  
  <p><strong>To list all entities</strong></p>
  
  <p><code>civicrm_api3('Entity', 'get');</code></p>
  
  <p><strong>To list fields for an entity</strong></p>
  
  <p><code>civicrm_api3('[EntityName]', 'getfields');</code></p>
  
  <p><strong>To list options for a field</strong> (only available for multiple choice fields):</p>
  
  <p><code>civicrm_api3('[EntityName]', 'getoptions', array( 'field' =&gt; "[FieldName]"));</code></p>
  
  <p><strong>To list actions for an entity</strong>:</p>
  
  <p><code>civicrm_api3('[EntityName]', 'getactions');</code></p>
  
  <p>FWIW, the above four API functions are used to build the API explorer, which is quite neat, IMO.</p>
  
  <p>As you might expect, in most cases the API is a fairly close match to the database structure.  This database structure is defined in a series of XML files that you can find in our git repo (for example <a href="https://github.com/civicrm/civicrm-core/blob/master/xml/schema/Contact/Group.xml" rel="nofollow">this xml file defines the table civicrm_group</a>).</p>
  
  <p>A couple of areas that merit a bit more explanation:</p>
  
  <ul>
  <li><p><strong>Custom data:</strong> At the database level, each <em>custom set</em> is a database table and each <em>custom field</em> is a database column.  All custom data is registered in two tables civicrm_custom_group and civicrm_custom_field.  These tables are exposed in the API as the entities CustomGroup and CustomField.</p></li>
  <li><p><strong>Options:</strong> At the database level, a lot of the simple drop-down options that you see in the user interface (for example <em>activity status</em>) are stored in the two tables civicrm_option_value and civicrm_option_group. These are exposed in the API as OptionValue and OptionGroup. The more complex options (for example <em>membership status</em>) typically  get their own table and API Entity.</p></li>
  </ul>
  
  <p>To answer the second question, when you say "patch the data-dictionary", I'm not entirely sure what you mean, but if you were "refining the core" and wanted to for example, add/edit/remove a field, I would</p>
  
  <ol>
  <li>Edit the xml file that creates the database table you are interested in</li>
  <li>"Run GenCode.php" to rebuild the data files</li>
  <li>Do various other things depending on what you changed!</li>
  </ol>
  
  <p>Of course if you are going down this route, I would recommend discussing any changes with someone who has a deep understanding of CiviCRM and its data structures.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-25T22:03:45.073Z
Answers.LastActivityDate: 2015-04-14T16:01:54.900Z
Answers.LastEditDate: 2015-04-14T16:01:54.900Z
Answers.UserDisplayName: michaelmcandrew
Answers.Body: <p>The <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Develop" rel="nofollow">developer documents</a> on the CiviCRM Wiki are very extensive and cover the codebase and development standards and best practices. There are <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Reference+Sheets" rel="nofollow">reference sheets</a> digging into specific areas for the project at hand. </p>
  
  <p>There are <a href="https://github.com/civicrm/civicrm-core/tree/master/xml/schema" rel="nofollow">XML files on GitHub</a> that describe the database structure and fields.</p>
  
  <p>Your CiviCRM instance should also have an API explorer and generator in civicrm/api/explorer as well as an API parameter list in civicrm/api/doc that are helpful.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-14T16:10:34.280Z
Answers.Text: The XML files are the definitive source
Answers.UserDisplayName: Donald Lobo
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-25T11:36:34.743Z
Answers.Text: So which is the *definitive* source?
Answers.UserDisplayName: ErichBSchulz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-25T09:00:56.103Z
Answers.LastActivityDate: 2015-03-25T09:00:56.103Z
Answers.UserDisplayName: James Bradach
Answers.Body: <p>There is no real data dictionary for CiviCRM. The data in core is generated from some xml schema's which you can find on GitHub at:
  <a href="https://github.com/civicrm/civicrm-core/tree/master/xml/schema" rel="nofollow">https://github.com/civicrm/civicrm-core/tree/master/xml/schema</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-25T21:17:09.470Z
Answers.Text: I am just upvoting this, simply because down votes are a bit uncool!
Answers.UserDisplayName: ErichBSchulz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-02T07:12:16.123Z
Answers.Text: By the way, Erich if you do access the database directly (and Xavier's eyes are averted) I assume you do use the CRM_Core_DAO::executeQuery method?
Answers.UserDisplayName: ErikH - CiviCooP
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-25T13:53:08.950Z
Answers.LastActivityDate: 2015-04-12T00:45:00.410Z
Answers.LastEditDate: 2015-04-12T00:45:00.410Z
Answers.UserDisplayName: ErikH - CiviCooP
Answers.Body: <p>I think the best answer it the one that points folk to <a href="https://doc.symbiotic.coop/dev/civicrm/latest/schema/index.html" rel="nofollow noreferrer">https://doc.symbiotic.coop/dev/civicrm/latest/schema/index.html</a> which is derived using SchemaSpy per the answer here</p>
  
  <p><a href="https://civicrm.stackexchange.com/a/20160/96">https://civicrm.stackexchange.com/a/20160/96</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-12T05:16:15.643Z
Answers.LastActivityDate: 2018-11-12T05:16:15.643Z
Answers.UserDisplayName: petednz - fuzion
Body: <p>In a variety of contexts it is useful to have a Entity Relationship Diagram (ERD) / data-dictionary:</p>
  
  <ul>
  <li>Using the API</li>
  <li>(Xavier avert your eyes) querying the database with SQL</li>
  <li>Developing extensions; and even</li>
  <li>Refining the core.</li>
  </ul>
  
  <p>Where is the definitive data-dictionary for CiviCRM? And how do we patch it?</p>
  
Tags: <api><sql>
Title: Where is the CiviCRM ERD / data-dictionary?
ThreadText: # Where is the CiviCRM ERD / data-dictionary?
  
  (Asked by: username_0 on 2015-03-25)
  
  In a variety of contexts it is useful to have a Entity Relationship Diagram (ERD) / data-dictionary:
  
  * Using the API
  * (Xavier avert your eyes) querying the database with SQL
  * Developing extensions; and even
  * Refining the core.
  
  Where is the definitive data-dictionary for CiviCRM? And how do we patch it?
  
  **Tags:** api, sql
  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_1 on 2015-03-25. Score: 10 | Accepted answer
  
  You should use the **API** as the data dictionary. The **API explorer** (available in every installation) provides a convenient interface to browse the data dictionary.
  
  The demo sites each have an API explorer and they are the authoritative public data dictionary for CiviCRM. For example <http://dmaster.demo.civicrm.org/civicrm/api/explorer> (login first with username:demo and password:demo). [Other versions are also available.](https://civicrm.org/sandboxes).
  
  The entity select box shows a list of all available entities. For each entity, the three most important actions from a 'data dictionary' perspective are
  
  * **getfields** - for the given entity, this action shows available fields
  * **getactions** - for the given entity, this action shows available actions
  * **getoptions** - for the given entity *and field* this action shows available options (only available for multiple choice fields).
  
  Here are some examples of useful API calls:
  
  **To list all entities**
  
  `civicrm_api3('Entity', 'get');`
  
  **To list fields for an entity**
  
  `civicrm_api3('[EntityName]', 'getfields');`
  
  **To list options for a field** (only available for multiple choice fields):
  
  `civicrm_api3('[EntityName]', 'getoptions', array( 'field' => "[FieldName]"));`
  
  **To list actions for an entity**:
  
  `civicrm_api3('[EntityName]', 'getactions');`
  
  FWIW, the above four API functions are used to build the API explorer, which is quite neat, IMO.
  
  As you might expect, in most cases the API is a fairly close match to the database structure. This database structure is defined in a series of XML files that you can find in our git repo (for example [this xml file defines the table civicrm\_group](https://github.com/civicrm/civicrm-core/blob/master/xml/schema/Contact/Group.xml)).
  
  A couple of areas that merit a bit more explanation:
  
  * **Custom data:** At the database level, each *custom set* is a database table and each *custom field* is a database column. All custom data is registered in two tables civicrm\_custom\_group and civicrm\_custom\_field. These tables are exposed in the API as the entities CustomGroup and CustomField.
  * **Options:** At the database level, a lot of the simple drop-down options that you see in the user interface (for example *activity status*) are stored in the two tables civicrm\_option\_value and civicrm\_option\_group. These are exposed in the API as OptionValue and OptionGroup. The more complex options (for example *membership status*) typically get their own table and API Entity.
  
  To answer the second question, when you say "patch the data-dictionary", I'm not entirely sure what you mean, but if you were "refining the core" and wanted to for example, add/edit/remove a field, I would
  
  1. Edit the xml file that creates the database table you are interested in
  2. "Run GenCode.php" to rebuild the data files
  3. Do various other things depending on what you changed!
  
  Of course if you are going down this route, I would recommend discussing any changes with someone who has a deep understanding of CiviCRM and its data structures.
  
  
  ---
  
  ### Answer by username_2 on 2015-03-25. Score: 4
  
  The [developer documents](http://wiki.civicrm.org/confluence/display/CRMDOC/Develop) on the CiviCRM Wiki are very extensive and cover the codebase and development standards and best practices. There are [reference sheets](http://wiki.civicrm.org/confluence/display/CRMDOC/Reference+Sheets) digging into specific areas for the project at hand.
  
  There are [XML files on GitHub](https://github.com/civicrm/civicrm-core/tree/master/xml/schema) that describe the database structure and fields.
  
  Your CiviCRM instance should also have an API explorer and generator in civicrm/api/explorer as well as an API parameter list in civicrm/api/doc that are helpful.
  
  > **Comments:**
  > **username_0**: So which is the *definitive* source?  
  > **username_3**: The XML files are the definitive source  
  
  ---
  
  ### Answer by username_4 on 2015-03-25. Score: 2
  
  There is no real data dictionary for CiviCRM. The data in core is generated from some xml schema's which you can find on GitHub at:
  <https://github.com/civicrm/civicrm-core/tree/master/xml/schema>
  
  > **Comments:**
  > **username_0**: I am just upvoting this, simply because down votes are a bit uncool!  
  > **username_4**: By the way, Erich if you do access the database directly (and Xavier's eyes are averted) I assume you do use the CRM_Core_DAO::executeQuery method?  
  
  ---
  
  ### Answer by username_5 on 2018-11-12. Score: 0
  
  I think the best answer it the one that points folk to <https://doc.symbiotic.coop/dev/civicrm/latest/schema/index.html> which is derived using SchemaSpy per the answer here
  
  <https://civicrm.stackexchange.com/a/20160/96>
  
  
  ---
  
  