Database Source provider
The Database Source feeds data from local or external MySQL Database Tables, supporting Record and Records queries with relations and dynamic filtering and/or ordering.
Settings

| Setting | Description | Default |
|---|---|---|
| Name | The name that will identify this source instance. | |
| Default Cache Time | The default duration in seconds before the cache is renewed, set to 0 to disable caching. This setting can be overriden in each query configuration. | 3600 |

| Setting | Description | Required |
|---|---|---|
| Database | The name of the database to which to connect to. Defaults to the site database. | |
| Table | The table from which to create the source. | ✓ |
| Primary Key | The primary key of the selected table, this is specially important when using relations. | ✓ |
| Custom Connection | Should the connection to the database use custom connection instead of the site one. | |
| Relations | The list of relations and their configuration. |
The connection to the database will use the site configuration, but if Custom Connection is enabled the settings inputs will be used instead with support for local as remote servers.

| Setting | Description | Required |
|---|---|---|
| Host | The IP or domain of the database server. | ✓ |
| Port | The port which to use to connect to the server. | ✓ |
| Username / Password | The credentials which to use to connect to the server. | ✓ |
Complex data structures typically involve several tables related between them, if that's the case you can set as many relations as needed of the type:
| Type | Description |
|---|---|
| One to One | Also known as BelongsTo, where a single entry relates with another single entry, e.g. Article belongs to an Author. |
| One to Many | Also known as HasMany, where a single entry relates with multiple entries, e.g. Article is assigned to many Categories. |

| Setting | Description |
|---|---|
| Name | The name to associate the relation with. Should be meaningfull, e.g. Author. |
| Relation Type | The relation type, One to One or One to Many. |
| Related Table | The table that is being related with the main table. |
| Main Table Key | The column key from the main table to use for the relation. |
| Related Table Key | The column key from the related table to use for the relation. |
MySQL Views
Relations can get complex and difficult to debug, an alternative simpler approach is to create a MySQL View with the relations solved and use that view as the main table.
Record Query
Fetches a single record from the table and resolves to a dynamically generated record type based on the table schema.

| Setting | Description | Default | Dynamic |
|---|---|---|---|
| Filters | The list of filter conditions applied to the query. | [] | ✓ |
| Ordering | The list of ordering conditions applied to the query. | [] | ✓ |
| Random | Should the ordering be randomized ignoring any ordering condition. | false | |
| Start | The offset applied to the query. | 1 | ✓ |
| Cache | The duration in seconds before the cache is invalidated and the query re-executed. | 3600 |
Records Query
Fetches records from the table and resolves to a dynamically generated list of record type based on the table schema.

| Setting | Description | Default | Dynamic |
|---|---|---|---|
| Filters | The list of filter conditions applied to the query. | [] | ✓ |
| Ordering | The list of ordering conditions applied to the query. | [] | ✓ |
| Random | Should the ordering be randomized ignoring any ordering condition. | false | |
| Start | The offset applied to the query. | 1 | ✓ |
| Quantity | The limit applied to the query. | 20 | ✓ |
| Cache | The duration in seconds before the cache is invalidated and the query re-executed. | 3600 |