...
- An anchor is a fragment, as such it can have properties
- The first element of the xpath array is the name of the anchor. All the children append elements to that.
- All the fragments have a reference to the anchor point.
- The full xpath is stored as text
- The parent ID column in the fragment table is there for transactional integrity. It references the id column to prevent creating orphan records under concurrency. It also serves lookup performance for parent/children.
- A schema node identifier can be inferred from the xpath (in fact, for containers it is the xpath bar the first element). There is no need to link it to a model set.
- The link between anchor points and module sets is purely for storing the association. The DB SPI has no notion of the model semantics.
The proposed DB for this schema is Postgres (as it uses some Postgres specific datatypes)
Note the 1. The module_set table above will not be used like this in the PoC instead we will start with a ‘modules’ table which will contain the complete source for each module. Including colums for namespace and revision.
Note 2. The latest DB Schema (as implemented) is documented on CPS Internal Relation DB Schema
2.2.1 Schema Code
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
CREATE TABLE RELATION_TYPE ( RELATION_TYPE TEXT NOT NULL, ID SERIAL PRIMARY KEY ); CREATE TABLE DATASPACE ( ID SERIAL PRIMARY KEY, NAME TEXT NOT NULL, CONSTRAINT "UQ_NAME" UNIQUE (NAME) ); CREATE TABLE SCHEMA_NODE ( SCHEMA_NODE_IDENTIFIER TEXT NOT NULL, ID SERIAL PRIMARY KEY ); CREATE TABLE MODULE_SET ( MODULE_SET_REFERENCE TEXT NOT NULL, ID SERIAL PRIMARY KEY ); CREATE TABLE FRAGMENT ( ID BIGSERIAL PRIMARY KEY, XPATH TEXT NOT NULL, DATASPACE_ID INTEGER NOT NULL REFERENCES DATASPACE(ID), ATTRIBUTES JSONB, ANCHOR_ID BIGINT REFERENCES FRAGMENT(ID), PARENT_ID BIGINT REFERENCES FRAGMENT(ID), MODULE_SET_ID INTEGER REFERENCES MODULE_SET(ID), SCHEMA_NODE_ID INTEGER REFERENCES SCHEMA_NODE(ID) ); CREATE TABLE RELATION ( FROM_FRAGMENT_ID BIGINT NOT NULL REFERENCES FRAGMENT(ID), TO_FRAGMENT_ID BIGINT NOT NULL REFERENCES FRAGMENT(ID), RELATION_TYPE_ID INTEGER NOT NULL REFERENCES RELATION_TYPE(ID), FROM_REL_XPATH TEXT NOT NULL, TO_REL_XPATH TEXT NOT NULL, CONSTRAINT RELATION_PKEY PRIMARY KEY (TO_FRAGMENT_ID, FROM_FRAGMENT_ID, RELATION_TYPE_ID) ); CREATE INDEX "FKI_FRAGMENT_DATASPACE_ID_FK" ON FRAGMENT USING BTREE(DATASPACE_ID) ; CREATE INDEX "FKI_FRAGMENT_MODULE_SET_ID_FK" ON FRAGMENT USING BTREE(MODULE_SET_ID) ; CREATE INDEX "FKI_FRAGMENT_PARENT_ID_FK" ON FRAGMENT USING BTREE(PARENT_ID) ; CREATE INDEX "FKI_FRAGMENT_ANCHOR_ID_FK" ON FRAGMENT USING BTREE(ANCHOR_ID) ; CREATE INDEX "PERF_SCHEMA_NODE_SCHEMA_NODE_ID" ON SCHEMA_NODE USING BTREE(SCHEMA_NODE_IDENTIFIER) ; CREATE INDEX "FKI_SCHEMA_NODE_ID_TO_ID" ON FRAGMENT USING BTREE(SCHEMA_NODE_ID) ; CREATE INDEX "FKI_RELATION_TYPE_ID_FK" ON RELATION USING BTREE(RELATION_TYPE_ID); CREATE INDEX "FKI_RELATIONS_FROM_ID_FK" ON RELATION USING BTREE(FROM_FRAGMENT_ID); CREATE INDEX "FKI_RELATIONS_TO_ID_FK" ON RELATION USING BTREE(TO_FRAGMENT_ID); CREATE INDEX "PERF_MODULE_SET_MODULE_SET_REFERENCE" ON MODULE_SET USING BTREE(MODULE_SET_REFERENCE) ; CREATE UNIQUE INDEX "UQ_FRAGMENT_XPATH"ON FRAGMENT USING btree(xpath COLLATE pg_catalog."default" text_pattern_ops, dataspace_id); |
...