aboutsummaryrefslogtreecommitdiffstats
path: root/notes/data_model.md
blob: fe21b5333f6555993cf497cdc94fb79eb1a3423f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92

## Cookbook

To create a new works:

    login/create account

    match/lookup on first work; if found, modify not create
    TODO: match/lookup on files?

    new edit group (under account; wip)
    new edit (under group)

    match/lookup on all creators
    match/lookup on all refs
      TODO: match/lookup on files?
    match/lookup container

    new work_rev (linked to edit)
    new work_ident (linked to rev; not-live)
    contributor stubs/links
    new release_rev (linked to work_ident)
    new release_ident (linked to rev; not-live)
    contributor stubs/links
    ref stubs/links
    new file_rev
    new file_ident

    set edit group state to "review"

    set edit group state to "accepted"
    set all ident flags to "live"


To edit, eg, a contributor:

    new edit group (under account; wip)
    new edit (under group)

    create contributor_rev row (and relationship rows)

    set edit group state to "review"

    set edit group state to "accepted"
    point ident row to new rev


Accept edit group:

    for each edit:
      update entity ident state (activate, redirect, delete)
      ? mark revision/edit as immutable
      ? append log/changelog row
    update edit group state

## Entity Schema

Each entity type has tables:

    _rev
      core representation of a version of the entity

    _ident
      persistant, external identifier
      allows merging, unmerging, stable cross-entity references

    _edit
      represents change metadata for a single change to one ident
      needed because an edit alwasy changes ident, but might not change rev

    _log
      history of when edits were actually applied
      allows fast lookups of history of an entity (ident)
      unnecessary if we keep a log of edit group accepts?
      punt on this for now

## Entity States

    wip (not live; not redirect; has rev)
      activate
    active (live; not redirect; has rev)
      redirect
      delete
    redirect (live; redirect; rev or not)
      split
      delete
    deleted (live; not redirect; no rev)
      redirect
      activate

    "wip redirect" or "wip deleted" are invalid states