err 297....
Posted in 1999
Topics: Server Administration, Triggers, Constraints & Referential Integrity
Dear informix supergurus:
1. I want to see more than the one-line-error-message at dbaccess, but
don't know howto....
2. I want to know why the heck error 297 appears as explained below...
please help !!!!!!!!!
--------
Damn error appears at creating the table "couplets"....
297: Cannot find unique constraint or primary key on referenced table
(is092756.morph_descrips)
Here is the sql.
--------------------------------------------
-- TAXA
--------------------------------------------
create table taxa (
taxon_id char(200) not null primary key,
rank text,
supertaxon_id text,
taxonomy text,
node_type char(1)
);
--------------------------------------------
-- CHARACTERISTICS (catalog of possible structure and characteristic names)
--------------------------------------------
create table characteristics
(
char_id char(200) not null primary key,
char_name char(200)
);
--------------------------------------------
-- MORPH_DESCRIPS (MORPHOLOGIC DESCRIPTIONs)
--------------------------------------------
create table morph_descrips
(
morph_id char(200) not null,
seq_no int not null,
char_id char(200) not null references characteristics,
value char(200),
parent_char_id char(200) references characteristics(char_id),
primary key (morph_id, seq_no)
);
--------------------------------------------
-- TYPICAL_SUBCHARS (typical struct/char organizations)
--------------------------------------------
create table typical_subchars
(
taxon_id char(200) not null,
char_id char(200) not null references characteristics,
parentchar_id char(200) not null references characteristics
);
--------------------------------------------
-- COUPLETS (components of taxonomic keys)
--------------------------------------------
create table couplets
(
taxon_id char(200) not null references taxa,
couplet_id text not null,
seq_no int not null,
parent_couplet_id text,
morph_id char(200) not null references morph_descrips(morph_id)
);
____roberto dircio palacios macedo__________________________________
__ | |
/\\_\\__ | Interactive and | http://ict.udlap.mx/people/roberto
\\/_/\\_\\ | Cooperative | tel:(22)292431
/\\_\\/_/ | Technologies Lab. | mail: is092756@cca.pue.udlap.mx
\\/_/ ict | UDLA-P, Mexico. |
__________|____________________|____________________________________
Just for the sake of it make sure you're always frowning
it shows the world that you have substance and depth. Tennant/Lowe
____________________________________________________________________
Roberto Dircio Palacios-Macedo wrote:
>
> Dear informix supergurus:
>
> 1. I want to see more than the one-line-error-message at dbaccess, but
> don't know howto....
finderr -297
> 2. I want to know why the heck error 297 appears as explained below...
Because there is not a unique constraint on morph_descrips(morph_id).
There is a unique index on morph_descrips(morph_id, seqno), but that
is no good in a references clause; you have to have a unique index on
exactly the columns referenced.
To fix your problem, I think I'd choose to create a table of
morphological features which is described by the morphological
descriptions:
CREATE TABLE morph_feature
(
morph_id CHAR(200) NOT NULL PRIMARY KEY,
char_id CHAR(200) NOT NULL,
parent_char_id CHAR(200) REFERENCES ...
);
CREATE TABLE morph_descrip
(
morph_id CHAR(200) NOT NULL REFERENCES morph_feature,
seqno INTEGER NOT NULL,
value CHAR(200) NOT NULL,
PRIMARY KEY(morph_id, seqno)
);
I'd also review very carefully why you are using CHAR(200) for
all these keys -- that is awfully big. There may be sound reasons,
but it feels a bit like overkill. Also, my design assumes that there's
a single char_id and parent_char_id for a single morph_feature, so
that if there a 6 rows in your version of morph_descrip for a
single morph_id, then all 6 rows have the same values for char_id
and parent_char_id. If that's wrong, then you have to move the
columns from morph_feature to morph_descrip.
> please help !!!!!!!!!
>
> --------
> Damn error appears at creating the table "couplets"....
>
> 297: Cannot find unique constraint or primary key on referenced table
> (is092756.morph_descrips)>
> Here is the sql.
>
> --------------------------------------------
> -- TAXA
> --------------------------------------------
> create table taxa (
> taxon_id char(200) not null primary key,
> rank text,
> supertaxon_id text,
> taxonomy text,
> node_type char(1)
> );>
> --------------------------------------------
> -- CHARACTERISTICS (catalog of possible structure and characteristic names)
> --------------------------------------------
> create table characteristics
> (
> char_id char(200) not null primary key,
> char_name char(200)
> );>
> --------------------------------------------
> -- MORPH_DESCRIPS (MORPHOLOGIC DESCRIPTIONs)
> --------------------------------------------
> create table morph_descrips
> (
> morph_id char(200) not null,
> seq_no int not null,
> char_id char(200) not null references characteristics,
> value char(200),
> parent_char_id char(200) references characteristics(char_id),
> primary key (morph_id, seq_no)
> );>
> --------------------------------------------
> -- TYPICAL_SUBCHARS (typical struct/char organizations)
> --------------------------------------------
> create table typical_subchars
> (
> taxon_id char(200) not null,
> char_id char(200) not null references characteristics,
> parentchar_id char(200) not null references characteristics
> );>
> --------------------------------------------
> -- COUPLETS (components of taxonomic keys)
> --------------------------------------------
> create table couplets
> (
> taxon_id char(200) not null references taxa,
> couplet_id text not null,
> seq_no int not null,
> parent_couplet_id text,
> morph_id char(200) not null references morph_descrips(morph_id)
> );
--
Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net)
Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN
#include <disclaimer.h>