Advertisement
brandizzi

"tables-on-tables" schema

Jan 5th, 2017
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.57 KB | None | 0 0
  1. CREATE TABLE Entity (
  2.   id     INTEGER PRIMARY KEY,
  3.   name   VARCHAR(100),
  4.   schema VARCHAR(400)
  5. );
  6.  
  7. CREATE TABLE FIELD (
  8.   id        INTEGER PRIMARY KEY,
  9.   entity_id INTEGER REFERENCES Entity(id),
  10.   TYPE      VARCHAR(20),
  11.   name      VARCHAR(100)
  12. );
  13.  
  14.  
  15. CREATE TABLE Instance (
  16.   id        INTEGER PRIMARY KEY,
  17.   entity_id INTEGER REFERENCES Entity(id),
  18.   DATA      BLOB
  19. );
  20.  
  21.  
  22. CREATE TABLE InstanceField (
  23.   id          INTEGER PRIMARY KEY,
  24.   field_id    INTEGER REFERENCES FIELD(id),
  25.   instance_id INTEGER REFERENCES Instance(id),
  26.   VALUE       VARCHAR(100)
  27. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement