1 -- The cvterm module design is based on the ontology
3 -- ================================================
5 -- ================================================
10 cvname varchar not null,
16 -- ================================================
18 -- ================================================
21 cvterm_id serial not null,
22 primary key (cvterm_id),
24 foreign key (cv_id) references cv (cv_id),
25 name varchar(255) not null,
27 -- the primary dbxref for this term. Other dbxrefs may be cvterm_dbxref
29 foreign key (dbxref_id) references dbxref (dbxref_id),
31 unique(termname, cv_id)
32 -- The unique key on termname, termtype_id ensures that all terms are
33 -- unique within a given cv
35 create index cvterm_idx1 on cvterm (cv_id);
38 -- ================================================
39 -- TABLE: cvrelationship
40 -- ================================================
42 create table cvrelationship (
43 cvrelationship_id serial not null,
44 primary key (cvrelationship_id),
45 reltype_id int not null,
46 foreign key (reltype_id) references cvterm (cvterm_id),
47 subjterm_id int not null,
48 foreign key (subjterm_id) references cvterm (cvterm_id),
49 objterm_id int not null,
50 foreign key (objterm_id) references cvterm (cvterm_id),
52 unique(reltype_id, subjterm_id, objterm_id)
54 create index cvrelationship_idx1 on cvrelationship (reltype_id);
55 create index cvrelationship_idx2 on cvrelationship (subjterm_id);
56 create index cvrelationship_idx3 on cvrelationship (objterm_id);
59 -- ================================================
61 -- ================================================
64 cvpath_id serial not null,
65 primary key (cvpath_id),
67 foreign key (reltype_id) references cvterm (cvterm_id),
68 subjterm_id int not null,
69 foreign key (subjterm_id) references cvterm (cvterm_id),
70 objterm_id int not null,
71 foreign key (objterm_id) references cvterm (cvterm_id),
73 foreign key (cv_id) references cv (cv_id),
76 unique (subjterm_id, objterm_id)
78 create index cvpath_idx1 on cvpath (reltype_id);
79 create index cvpath_idx2 on cvpath (subjterm_id);
80 create index cvpath_idx3 on cvpath (objterm_id);
81 create index cvpath_idx4 on cvpath (cv_id);
84 -- ================================================
85 -- TABLE: cvtermsynonym
86 -- ================================================
88 create table cvtermsynonym (
89 cvterm_id int not null,
90 foreign key (cvterm_id) references cvterm (cvterm_id),
91 termsynonym varchar(255) not null,
93 unique(cvterm_id, termsynonym)
95 create index cvterm_synonym_idx1 on cvterm_synonym (cvterm_id);
98 -- ================================================
99 -- TABLE: cvterm_dbxref
100 -- ================================================
102 create table cvterm_dbxref (
103 cvterm_dbxref_id serial not null,
104 primary key (cvterm_dbxref_id),
105 cvterm_id int not null,
106 foreign key (cvterm_id) references cvterm (cvterm_id),
107 dbxref_id int not null,
108 foreign key (dbxref_id) references dbxref (dbxref_id),
110 unique(cvterm_id, dbxref_id)
112 create index cvterm_dbxref_idx1 on cvterm_dbxref (cvterm_id);
113 create index cvterm_dbxref_idx2 on cvterm_dbxref (dbxref_id);