back to intro

LitSearch: SQL Schema

When translated into Oracle SQL, and after constraints and foreign keys are added, the schema becomes:

CREATE TABLE Author (
  name        varchar(128) primary key,
  birth       int,
  death       int,
  description clob
);

CREATE TABLE Criticism (
  title       varchar(255),
  critic      varchar(128),
  url         varchar(255) primary key,
  synopsis    clob,
  publication varchar(255),
  unique (title, critic)
);


CREATE TABLE Period (
  region    varchar(64),
  era       varchar(32),
  primary key(region, era)
);


CREATE TABLE Work (
  id           number(5) primary key,
  title        varchar(255),
  year         number(5),
  length       number(8) check (length >= 0)
);

CREATE TABLE Word (
  id      number(6) primary key,
  word    varchar(32)
);

CREATE TABLE WroteCriticism (
  url         varchar(255) references Criticism(url),
  name        varchar(128) references Author(name),
  primary key (url, name)
);

CREATE TABLE LivedIn (
  region    varchar(64),
  era       varchar(32),
  name      varchar(128) references Author(name),
  primary key (region, era, name),
  foreign key (region, era) references Period(region, era)
);

CREATE TABLE WrittenIn (
  region    varchar(64),
  era       varchar(32),
  work      number(5) references Work(id),
  primary key (region, era, work),
  foreign key (region, era) references Period(region, era)
);

CREATE TABLE Synonym (
  root   number(6) references Word(id),
  child  number(6) references Word(id),
  primary key (root, child)
);


CREATE TABLE Criticized (
  url     varchar(255) references Criticism(url),
  work    number(5) references Work(id),
  primary key (url, work)
);

CREATE TABLE WrittenBy (
  work   number(5) references Work(id),
  name   varchar(128) references Author(name),
  primary key (work, name)
);

CREATE TABLE Page (
  work        number(5),
  pageNumber  number(5),
  primary key (work, pageNumber)
);

CREATE TABLE Instance (
  word       number(6),
  work       number(5),
  pageNumber number(5),
  position   number(4),
  primary key (word, work, pageNumber)
);

CREATE TABLE WordContext (
  work       number(5),
  pageNumber number(5),
  position   number(4),
  actualText varchar(128),
  primary key (word, pageNumber, position)
);


Author: Keith Ito - September 2001