Convention for Database Tables

From Chorke Wiki
Revision as of 08:03, 16 September 2019 by Shahed (talk | contribs) (→‎Nomenclature)
Jump to navigation Jump to search
static char *base36enc(long unsigned int value) {
	char base36[36] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	/* log(2**64) / log(36) = 12.38 => max 13 char + '\0' */
	char buffer[14];
	unsigned int offset = sizeof(buffer);

	buffer[--offset] = '\0';
	do {
		buffer[--offset] = base36[value % 36];
	} while (value /= 36);

	return strdup(&buffer[offset]); // warning: this must be free-d by the user
}

static long unsigned int base36dec(const char *text) {
	return strtoul(text, NULL, 36);
}

Types of Table

Order Code Types Purpose Tables Views
F A Audit Audit Tables M00TA00X00 ~ MZZTAZZX00 M00VA00X00 ~ MZZVAZZXZZ
D E Entries Entries Tables M00TE00X00 ~ MZZTEZZX00 M00VE00X00 ~ MZZVEZZXZZ
A I Identity Identity Tables M00TI00X00 ~ MZZTIZZX00 M00VI00X00 ~ MZZVIZZXZZ
E J Join Join Tables n - n M00TJ00X00 ~ MZZTJZZX00 M00VJ00X00 ~ MZZVJZZXZZ
G L Local Local Tables M00TL00X00 ~ MZZTLZZX00 M00VL00X00 ~ MZZVLZZXZZ
B M Metadata Metadata Tables M00TM00X00 ~ MZZTMZZX00 M00VM00X00 ~ MZZVMZZXZZ
C S Settings Settings Tables M00TS00X00 ~ MZZTSZZX00 M00VS00X00 ~ MZZVSZZXZZ
H V Versions Versions Tables M00TV00X00 ~ MZZTVZZX00 M00VV00X00 ~ MZZVVZZXZZ

Nomenclature

[M]{1}────────────────M ─┐
                         │
[0-9A-Z]{2}───────────00─┼─M00T─┐
                         │      │
[T|V]{1}──────────────T ─┘      │
                                │
[A|E|I|J|L|M|S|V]{1}──M ─┐      │
                         ├─M00 ─┼─M00TM00X00
[0-9A-Z]{2}───────────00─┘      │
                                │
[X]{1}────────────────X ─┐      │
                         ├─X00 ─┘
[0-9A-Z]{2}───────────00─┘

Audit Tables

[M]{1}───────M ─┐
                │
[0-9A-Z]{2}──00─┼─M00T─┐
                │      │
[T|V]{1}─────T ─┘      │
                       │
[A]{1}───────A ─┐      │
                ├─A00 ─┼─M00TA00X00
[0-9A-Z]{2}──00─┘      │
                       │
[X]{1}───────X ─┐      │
                ├─X00 ─┘
[0]{2}───────00─┘

Entries Tables

[M]{1}───────M ─┐
                │
[0-9A-Z]{2}──00─┼─M00T─┐
                │      │
[T|V]{1}─────T ─┘      │
                       │
[E]{1}───────E ─┐      │
                ├─E00 ─┼─M00TE00X00
[0-9A-Z]{2}──00─┘      │
                       │
[X]{1}───────X ─┐      │
                ├─X00 ─┘
[0]{2}───────00─┘

Identity Tables

[M]{1}───────M ─┐
                │
[0-9A-Z]{2}──00─┼─M00T─┐
                │      │
[T|V]{1}─────T ─┘      │
                       │
[I]{1}───────I ─┐      │
                ├─I00 ─┼─M00TI00X00
[0-9A-Z]{2}──00─┘      │
                       │
[X]{1}───────X ─┐      │
                ├─X00 ─┘
[0]{2}───────00─┘

Join Tables

[M]{1}───────M ─┐
                │
[0-9A-Z]{2}──00─┼─M00T─┐
                │      │
[T|V]{1}─────T ─┘      │
                       │
[J]{1}───────J ─┐      │
                ├─J00 ─┼─M00TJ00X00
[0-9A-Z]{2}──00─┘      │
                       │
[X]{1}───────X ─┐      │
                ├─X00 ─┘
[0]{2}───────00─┘

Local Tables

[M]{1}───────M ─┐
                │
[0-9A-Z]{2}──00─┼─M00T─┐
                │      │
[T|V]{1}─────T ─┘      │
                       │
[L]{1}───────L ─┐      │
                ├─L00 ─┼─M00TL00X00
[0-9A-Z]{2}──00─┘      │
                       │
[X]{1}───────X ─┐      │
                ├─X00 ─┘
[0]{2}───────00─┘

Metadata Tables

[M]{1}───────M ─┐
                │
[0-9A-Z]{2}──00─┼─M00T─┐
                │      │
[T|V]{1}─────T ─┘      │
                       │
[M]{1}───────M ─┐      │
                ├─M00 ─┼─M00TM00X00
[0-9A-Z]{2}──00─┘      │
                       │
[X]{1}───────X ─┐      │
                ├─X00 ─┘
[0]{2}───────00─┘

Settings Tables

[M]{1}───────M ─┐
                │
[0-9A-Z]{2}──00─┼─M00T─┐
                │      │
[T|V]{1}─────T ─┘      │
                       │
[S]{1}───────S ─┐      │
                ├─S00 ─┼─M00TS00X00
[0-9A-Z]{2}──00─┘      │
                       │
[X]{1}───────X ─┐      │
                ├─X00 ─┘
[0]{2}───────00─┘

Versions Tables

[M]{1}───────M ─┐
                │
[0-9A-Z]{2}──00─┼─M00T─┐
                │      │
[T|V]{1}─────T ─┘      │
                       │
[V]{1}───────V ─┐      │
                ├─V00 ─┼─M00TV00X00
[0-9A-Z]{2}──00─┘      │
                       │
[X]{1}───────X ─┐      │
                ├─X00 ─┘
[0]{2}───────00─┘

References