MDriven administrative database tables
No edit summary
No edit summary
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
When you create a database from a model these administrative tables will be added automatically for you.
==== New 2024-02-18; Use MDrivenServer to create the admin tables instead of manually as described below: ====
This is described in this video: https://youtu.be/BmmoAFjaQtc
[[File:MDriven administrative database tables 1708287873349.png|none|thumb|667x667px]]


But when [[Training:Reverse engineer a database|reversing an existing database]] to a model - and then wanting to use the model just like any another MDriven Model you may find that you need to add these manually.
 
==== Manual process ====
When you create a database from a model, these administrative tables will be added automatically for you.
 
However, when [[Training:Reverse engineer a database|reversing an existing database]] to a model - and then wanting to use the model just like any another MDriven Model, you may find that you need to add these manually.


Below is the script and explanation of what the table is for:
Below is the script and explanation of what the table is for:
Line 10: Line 16:
!
!
!
!
!PostgreSQL
|-
|-
|ECO_ID
|ECO_ID
Line 29: Line 36:


) ON [PRIMARY]
) ON [PRIMARY]
|CREATE TABLE eco_id (
    pk SERIAL primary key,
    bold_id INT NOT NULL
);
|-
|-
|ECO_ORMAPPING
|ECO_ORMAPPING
Line 51: Line 64:


GO
GO
|<code>CREATE TABLE eco_ormapping (
id SERIAL PRIMARY KEY,
eco_ormapping TEXT NOT NULL
);</code>
|-
|-
|ECO_TABLES
|ECO_TABLES
Line 61: Line 78:


GO
GO
|<code>CREATE TABLE eco_tables (
tablename VARCHAR(255) NOT NULL
);</code>
|-
|-
|ECO_TYPE
|ECO_TYPE
Line 81: Line 101:


GO
GO
|<code>CREATE TABLE eco_type (
eco_type SMALLINT NOT NULL,
classname VARCHAR(255) NOT NULL,
PRIMARY KEY (eco_type)
);</code>
|-
|-
|
|
|
|
|
Line 87: Line 113:
|
|
|}
|}
{{Edited|July|12|2024}}
[[Category:MDriven Server]]

Revision as of 05:44, 18 March 2024

New 2024-02-18; Use MDrivenServer to create the admin tables instead of manually as described below:

This is described in this video: https://youtu.be/BmmoAFjaQtc

MDriven administrative database tables 1708287873349.png


Manual process

When you create a database from a model, these administrative tables will be added automatically for you.

However, when reversing an existing database to a model - and then wanting to use the model just like any another MDriven Model, you may find that you need to add these manually.

Below is the script and explanation of what the table is for:

Table name PostgreSQL
ECO_ID This is the cursor of the default internal key assigned to objects saved with the default persistence mapper.

This table only has 1 row holding the next free identity for a new object

CREATE TABLE [dbo].[ECO_ID](

[PK] [int] NOT NULL,

[BOLD_ID] [int] NOT NULL,

CONSTRAINT [PK_ECO_ID] PRIMARY KEY CLUSTERED

(

[PK] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

CREATE TABLE eco_id (

    pk SERIAL primary key,

    bold_id INT NOT NULL

);

ECO_ORMAPPING This holds a text-blob with the OR-mapping in MDrivenFormat (xml). MDriven reads this upon evolve of database to figure out what we has changed compared to the current model.

After successfull evolve MDriven writes the updated OR-mapping to this column. The Table only holds 1 row

CREATE TABLE [dbo].[ECO_ORMAPPING](

[ID] [int] NOT NULL,

[ECO_ORMAPPING] [ntext] NOT NULL,

PRIMARY KEY CLUSTERED

(

[ID] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

CREATE TABLE eco_ormapping (

id SERIAL PRIMARY KEY, eco_ormapping TEXT NOT NULL );

ECO_TABLES This table has one row per table that MDriven has created or taken ownership of in your database. CREATE TABLE [dbo].[ECO_TABLES](

[TABLENAME] [nvarchar](255) NOT NULL

) ON [PRIMARY]

GO

CREATE TABLE eco_tables (

tablename VARCHAR(255) NOT NULL );

ECO_TYPE This table holds the class names from your model along with an integer number unique to that type. If MDriven is instructed to write many types to the same table (OR-Parent-Mapping) MDriven figures out the runtime type by lookin the ECO_TYPE column of such a table - and the number will match a number in the ECO_TYPE table. CREATE TABLE [dbo].[ECO_TYPE](

[ECO_TYPE] [smallint] NOT NULL,

[CLASSNAME] [nvarchar](255) NOT NULL,

PRIMARY KEY CLUSTERED

(

[ECO_TYPE] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

GO

CREATE TABLE eco_type (

eco_type SMALLINT NOT NULL, classname VARCHAR(255) NOT NULL, PRIMARY KEY (eco_type) );

This page was edited 13 days ago on 04/30/2024. What links here