|
1 | 1 | # Database Schema |
2 | 2 |
|
3 | 3 | The Imixs-Workflow engine persists all information about the model and the running workflow instances (_workitems_) using the Java Persistence API (JPA). Therefore the Imixs-Workflow engine is database vendor independent and can be run on any SQL database (e.g. MySQL, PostgreSQL, Oracle, MS SQL, ...). See the [Deployment Guide](./deployment_guide.html) for further details how to deploy the Imixs-Workflow engine into a application sever. |
4 | | - |
| 4 | + |
5 | 5 | ## The JPA Classes and Tables |
6 | | -The database schema used by the Imixs-Workflow engine is quite simple and constis of only one table named '_DOCUMENT_'. During the deployment, JPA maps the jpa class _org.imixs.workflow.engine.jpa.Document_ automatically to the database and creates the corresponding data table. |
7 | 6 |
|
| 7 | +The database schema used by the Imixs-Workflow engine is quite simple and consists of only two tablee named `DOCUMENT` and `EVENTLOG`. During the deployment, JPA maps the jpa entity classes automatically to the database and creates the corresponding data table. |
| 8 | + |
| 9 | +If you like to to create the table manually you can do it like this: |
| 10 | + |
| 11 | +```sql |
| 12 | +CREATE TABLE document2 ( |
| 13 | + id character varying(255) NOT NULL, |
| 14 | + created timestamp without time zone, |
| 15 | + data bytea, |
| 16 | + modified timestamp without time zone, |
| 17 | + type character varying(255), |
| 18 | + version integer |
| 19 | +); |
| 20 | + |
| 21 | +ALTER TABLE document ADD CONSTRAINT document_pkey PRIMARY KEY (id); |
| 22 | +``` |
| 23 | + |
| 24 | +```sql |
| 25 | +CREATE TABLE eventlog ( |
| 26 | + id character varying(255) NOT NULL, |
| 27 | + created timestamp without time zone, |
| 28 | + data bytea, |
| 29 | + ref character varying(255), |
| 30 | + timeout timestamp without time zone, |
| 31 | + topic character varying(255), |
| 32 | + version integer |
| 33 | +); |
| 34 | + |
| 35 | +ALTER TABLE eventlog ADD CONSTRAINT eventlog_pkey PRIMARY KEY (id); |
| 36 | +``` |
8 | 37 |
|
9 | | - CREATE TABLE `DOCUMENT` ( |
10 | | - `ID` varchar(255) NOT NULL, |
11 | | - `CREATED` datetime DEFAULT NULL, |
12 | | - `DATA` longblob, |
13 | | - `MODIFIED` datetime DEFAULT NULL, |
14 | | - `TYPE` varchar(255) DEFAULT NULL, |
15 | | - `VERSION` int(11) DEFAULT NULL, |
16 | | - PRIMARY KEY (`ID`) |
17 | | - ) ENGINE=InnoDB DEFAULT CHARSET=latin1; |
| 38 | +## Performance |
18 | 39 |
|
| 40 | +In large databases with many documents it is recommended to provide additional indexes to the following columns: |
19 | 41 |
|
| 42 | +- type |
| 43 | +- created |
| 44 | +- modified |
| 45 | +- version |
20 | 46 |
|
21 | | -## Performance |
22 | | -In large databases with many documents it is recommended to provide additional indexes to the following columns: |
| 47 | +### MySQL |
23 | 48 |
|
24 | | - * type |
25 | | - * created |
26 | | - * modified |
27 | | - * version |
28 | | - |
29 | | - |
30 | | -### MySQL |
| 49 | +The following statement adds the necessary indexes for a MySQL Database: |
31 | 50 |
|
32 | | -The following statement adds the necessary indexes for a MySQL Database: |
33 | | - |
34 | | - ALTER TABLE `DOCUMENT` ADD INDEX `index1`(`CREATED`,`MODIFIED`,`TYPE`,`VERSION`); |
| 51 | + ALTER TABLE `DOCUMENT` ADD INDEX `index1`(`CREATED`,`MODIFIED`,`TYPE`,`VERSION`); |
35 | 52 |
|
36 | 53 | ### PostgreSQL |
37 | 54 |
|
38 | | -The following statement adds the necessary indexes for a PostgreSQL Database: |
| 55 | +The following statement adds the necessary indexes for a PostgreSQL Database: |
| 56 | + |
| 57 | + CREATE INDEX index_document1 ON document USING btree(created, modified, type , version); |
39 | 58 |
|
40 | | - CREATE INDEX index_document1 ON document USING btree(created, modified, type , version); |
41 | | - |
|
0 commit comments