Subject Re: [ib-support] Is there any UNIQUE limit?
Author Raul Chirea
Matteo,

From: "Nando Dessena" <nandod@...>

> index in two or three (non unique) slices, and then enforce uniqueness
> by means of a trigger or two.
> This has some disadvantages, too.

In fact, the disadvantage is that the uniqueness can not be enforced with
triggers ! IB has a stupid low (about 200-300 bytes - I don't know for sure
but is documented) limit for an index size. So, if you want uniqueness you
should use smaller fields in the unique key. This could be done by
indirection of large fields like this:

create table FILES (
id integer not null,
file varchar(200) not null,
constraint FILES_PK primary key (id, file)
);

Same way:

create table PERCORSOS (
...

Note that a primary key is allways an unique one, and the theory said that
each table should have one.
After this you can make a reference in your table to a file by it's ID, like
this:

CREATE TABLE TEST (
Protocollo SMALLINT NOT NULL,
Host SMALLINT NOT NULL,
Porta SMALLINT NOT NULL,
Percorso_id integer NOT NULL,
File_id integer NOT NULL,
Status SMALLINT DEFAULT '0',
CONSTRAINT test_pk PRIMARY KEY (Host, Percorso_id, File_id),
CONSTRAINT test_file_fk FOREIGN KEY (File_id) REFERENCES files (ID),
CONSTRAINT test_percorsos_fk FOREIGN KEY (Percorso_id) REFERENCES
percorsos (ID)
);

Note that I don't know what "percorso" means and it may sound strange or
stupid.
Anyway, this is just a posibility, your imagination may find others. The
ideea is not having very large keys (it is good for performance, too).

Raul.



-------------------------------------------------------
Xnet scaneaza automat toate mesajele impotriva virusilor folosind RAV AntiVirus.
Xnet automatically scans all messages for viruses using RAV AntiVirus.

Nota: RAV AntiVirus poate sa nu detecteze toti virusii noi sau toate variantele lor. Va rugam sa luati in considerare ca exista un risc de fiecare data cand deschideti fisiere atasate si ca MobiFon nu este responsabila pentru nici un prejudiciu cauzat de virusi.
Disclaimer: RAV AntiVirus may not be able to detect all new viruses and variants. Please be aware that there is a risk involved whenever opening e-mail attachments to your computer and that MobiFon is not responsible for any damages caused by viruses.