The following DDLs on slide "JDBC HOW TO" page for MySQL:
"
create table objects(uri blob not null, primary key uriIndex (uri(255)),
classname blob);
create table revisions(uri blob not null, primary key uriIndex
(uri(255)), isversioned int, initialrevision varchar(10) );
"
are logically incorrect, I think. It enforces the uniqueness
on the first 255 bytes of "uri" of the type BLOB, while the uniqueness
is only required on the entire "uri" column. The primary key
would reject valid "uri" rows.
This point is demonstrated with following example (uses 10 instead 255):
mysql> create table a (uri blob not null, primary key (uri(10)));
Query OK, 0 rows affected (0.17 sec)
mysql> insert into a values ('/234567890/a');
Query OK, 1 row affected (0.21 sec)
mysql> insert into a values ('/234567890/b');
ERROR 1062: Duplicate entry '/234567890/b' for key 1
On Fri, Nov 15, 2002, Martin Holz (<[EMAIL PROTECTED]>) wrote:
> [The primary key is] just a guard against bugs in slide.
> However you still need a index on uri to get acceptable performance.
For this reason, and the reason I mentioned above, the "primary key"
should be replaced by "key" in the DDL statements.
This would allows URIs with common path >= 255 bytes. However, if you
many URIs like this, the index would not be selective. But this is a
performance issue.
Thanks.
--
Michael Wang
http://www.unixlabplus.com/
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>