Skip to content

Instantly share code, notes, and snippets.

@aryairani
Created March 9, 2022 20:42
Show Gist options
  • Save aryairani/b4944eb71ad6dfb6e57f8bd7bd936d29 to your computer and use it in GitHub Desktop.
Save aryairani/b4944eb71ad6dfb6e57f8bd7bd936d29 to your computer and use it in GitHub Desktop.
relational namespace draft June 2021
CREATE TABLE namespace_term (
id INTEGER PRIMARY KEY NOT NULL,
namesegment_id INTEGER NOT NULL REFERENCES text(id),
referent_object_id INTEGER NOT NULL REFERENCES object(id),
referent_component_id INTEGER NOT NULL,
referent_constructor_id INTEGER NULL,
);
CREATE INDEX namespace_term_name ON namespace_term (
namesegment_id
);
CREATE INDEX namespace_term_ref ON namespace_term (
referent_object_id,
referent_component_id,
referent_constructor_id,
namesegment_id
);
CREATE TABLE namespace_type (
id INTEGER PRIMARY KEY NOT NULL,
namesegment_id INTEGER NOT NULL REFERENCES text(id),
reference_object_id INTEGER NOT NULL REFERENCES object(id),
reference_component_id INTEGER NOT NULL,
);
CREATE INDEX namespace_type_name ON namespace_type(
namesegment_id
);
CREATE INDEX namespace_type_reference ON namespace_type (
reference_object_id,
reference_component_id,
namesegment_id
);
CREATE TABLE namespace_patch (
id INTEGER PRIMARY KEY NOT NULL,
namesegment_id INTEGER NOT NULL REFERENCES text(id),
patch_object_id INTEGER NOT NULL REFERENCES object(id)
);
CREATE INDEX namespace_patch_name ON namespace_patch(
namesegment_id, patch_object_id
);
CREATE TABLE namespace_child (
namespace_hash_id INTEGER NOT NULL REFERENCES hash(id),
child_hash_id INTEGER NOT NULL REFERENCES hash(id),
PRIMARY KEY (namespace_hash_id, child_hash_id)
) WITHOUT ROWID;
CREATE INDEX namespace_child_child ON namespace_child(child_hash_id, namespace_hash_id);
CREATE TABLE namespace_term_metadata (
namespace_hash_id INTEGER NOT NULL REFERENCES hash(id),
namespace_term_id INTEGER NOT NULL REFERENCES namespace_term(id),
metadata_object_id INTEGER NOT NULL REFERENCES object(id),
metadata_component_id INTEGER NOT NULL,
PRIMARY KEY (
namespace_hash_id,
namespace_term_id,
metadata_object_id,
metadata_component_id
)
) WITHOUT ROWID;
CREATE INDEX namespace_term_metadata_metadata
ON namespace_term_metadata(
metadata_object_id, metadata_component_id
);
CREATE TABLE namespace_type_metadata (
namespace_hash_id INTEGER NOT NULL REFERENCES hash(id),
namespace_term_id INTEGER NOT NULL REFERENCES namespace_term(id),
metadata_object_id INTEGER NOT NULL REFERENCES object(id),
metadata_component_id INTEGER NOT NULL,
PRIMARY KEY (
namespace_hash_id,
namespace_term_id,
metadata_object_id,
metadata_component_id
)
) WITHOUT ROWID;
CREATE INDEX namespace_type_metadata_metadata
ON namespace_type_metadata(
metadata_object_id, metadata_component_id
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment