What would you like to know more about?

Show Page Sections

Database Relationships

A brief overview of relationships mean in a Relational Database like MinistryPlatform.

Each table in a Relational Database contains one kind of record. Those records relate to each other using special columns to tie them together. These special columns are known as primary and foreign keys. Below is a partial representation of the table relationships centered around Contacts. For a data dictionary of all database tables in HTML format, email Support.

A flow chart of how tables in a Relational Database connect to each other

Finding Relationships in MinistryPlatform

There is much evidence of these primary and foreign key relationships in the Platform. Here are three:

Advanced Search

The expandable folders in Advanced Search represent foreign keys. When you select these, the Platform adds a JOIN to your query to get fields from related tables. The Advanced Search uses the Table Lookup Convention to represent table joins.

The Advanced Search Tool dialog box

Link Navigation

The small link icons represent foreign keys and related tables. Click these links to follow the relationships to pages which represent the related tables. Click the link next to Contact Status: Active to go to the Contact Statuses page, landing on the record "Active."

Jennifer Anderson's Contact record, with a blue link icon for Contact Status: Active

Drop-Down Lists & Pick-Lists

When editing a record, drop-down lists and pick-lists represent foreign keys. When you select an item, you store the primary key value of a related table in the foreign key column of the page table.

Jennifer Anderson's Contact record, with the Gender drop-down list displayed

Data Models & Tables

A guide outlining the different types of SQL relationships and tables you'll find in the Platform.

One-To-Many

In one-to-many relationships, the data uses a foreign key in the "one" which matches the primary key in the "many".

Contacts > Contact Statuses

A Contact has one Contact Status. Many Contacts can have Contact Statuses.

Diagram showing the relationship between the tables for Contacts and Contact_Statuses

Contacts > Households > Congregations

A Contact has one Household. Households can have many Contacts.

A Household has one Congregation. Congregations can have many Households.

Diagram showing the relationship between the tables for contacts, households, and congregations

Many-To-Many

To model many-to-many relationships, use a third table (an associative table) to associate two indirectly related tables. The associative table contains a foreign key for the primary keys in the two "many" tables.

Groups > Group Participants > Participants

A Group can have many Participants. A Participant can be in many Groups.

Diagram showing the relationship between the tables for groups, group_participants, and participants

Audit Log Tables

The following tables store the Audit Log. You can't directly access the tables in the Platform, but you can use them in your views.

See the Contact Changes View Example.

Diagram showing tables for dp_users, dp_audit_log, and dp_audit_detail

To establish a relationship between dp_Audit_Log and the page that has your view, define the Table_Name. For example, Table_Name = 'Events'.

Contact Tables

The following tables are closely related to Contacts. This is only a partial representation.

Diagram showing tables for prefixes, marital_statuses, contact_statuses, donors, dp_users, contacts, suffixes, genders, households, participants, addresses, congregations, and household_positions

Files Table

This table stores information about all attached files. You can't directly access this table in the Platform, but you can use it in your views.

See the Contacts With Files View Example.

Diagram showing the dp_files table

Series Tables

The following tables store series. You can't directly access these tables in the Platform, but you can use them in your views.

Diagram showing tables for dp_sequences and dp_sequence_records

Series records use a soft join because they can refer to multiple tables. The Table_Name column matches the name of the table and Record_ID matches the primary key for the sequence. For example, the following SQL returns the sequence for the Event 1783:

SELECT SR.Sequence_ID 
FROM dp_Sequence_Records SR 
WHERE SR.Table_Name = 'Events' AND SR.Record_ID = 1783

See the Events In Series View Example for an example.

Task & Submission Tables

This group of tables stores information about all tasks and the status of active process submissions, including the current step.

See the Contacts With Tasks View Example.

Diagram showing tables for dp_users, dp_tasks, dp_process_submissions, dp_processes, dp_process_submission_statuses, and dp_process_steps