plugin:struct:dbinternals
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
plugin:struct:dbinternals [2022-05-05 13:37] – created andi | plugin:struct:dbinternals [2024-04-22 10:23] (current) – [Data] asheenlevrai | ||
---|---|---|---|
Line 2: | Line 2: | ||
====== Database Internals ====== | ====== Database Internals ====== | ||
- | The struct plugin maps the a relatively dynamic schema mechanism on a much more rigid relational database system. It also needs to take care that schemas evolve over time, but data in the past has to be preserved and the appropriate schema at that time need to be used. | + | The struct plugin maps a relatively dynamic schema mechanism on a much more rigid relational database system. It also needs to take care that schemas evolve over time, but data in the past has to be preserved and the appropriate schema at that time need to be used. |
- | To do this, schemas in struct do not map directly to tables in the database. | + | To do this, schemas in struct do not directly |
+ | |||
+ | Generally you should not need to know about any of these internals, but it might be helpful for developers. | ||
+ | |||
+ | ===== Schema Management ===== | ||
+ | |||
+ | The schemas themselves are managed in three tables: | ||
+ | |||
+ | * '' | ||
+ | * manages the schema name and meta configuration (like editors and translated schema label) | ||
+ | * a new entry is saved every time the schema is edited, the newest version has the largest timestamp in the '' | ||
+ | * using the '' | ||
+ | * '' | ||
+ | * defines the type and configuration of the fields in the schemas and contains the visible name used for this field | ||
+ | * '' | ||
+ | * defines which fields are in a schema, in what order to display them and if they are currently enabled | ||
+ | * '' | ||
+ | |||
+ | Here is a select that will, select the most current schema versions and their currently enabled columns: | ||
<code sql> | <code sql> | ||
- | SELECT S.ts, S.tbl, T.label, SC.colref, T.ismulti | + | |
- | FROM schemas S, | + | FROM schemas S, |
- | | + | |
- | | + | |
- | WHERE SC.sid = S.id | + | |
- | | + | |
- | | + | |
GROUP BY S.tbl, T.label | GROUP BY S.tbl, T.label | ||
- | HAVING MAX(S.ts) | + | |
ORDER BY S.tbl, SC.sort | ORDER BY S.tbl, SC.sort | ||
- | ; | ||
- | |||
</ | </ | ||
- | FIXME work in progress... | + | ===== Data ===== |
+ | |||
+ | Data is stored | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | For single value field values are stored in columns named '' | ||
+ | |||
+ | For multivalue field values, one row per value is used in the table with a '' | ||
+ | |||
+ | |||
+ | All data tables have the following meta data: | ||
+ | |||
+ | * '' | ||
+ | * The page id this data is associated with (for page and serial data) | ||
+ | * '' | ||
+ | * '' | ||
+ | * A row counter for serial and global data | ||
+ | * '' | ||
+ | * '' | ||
+ | * the page revision this data is associated with (for page data) | ||
+ | * '' | ||
+ | * '' | ||
+ | * a boolean to show if this is the newest available data for this field (simplifies selects for current data) | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | NOTE: correct me if I'm wrong but it seems to me like there is a mistake in the image above. | ||
+ | For the //Serial Schema// table: | ||
+ | |||
+ | the values for the //field1// column should be aaa (not xyz) for RID=1 and bbb (not zyc) for RID=2, right? | ||
+ | |||
+ | Similarly, | ||
+ | |||
+ | the values for the //field2// column should be xxx (not 34) for RID=1 and yyy (not 22) for RID=2, right? | ||
+ |
plugin/struct/dbinternals.1651750632.txt.gz · Last modified: 2022-05-05 13:37 by andi