[thelist] Multi-level data storage

Andrew Forsberg andrew at thepander.co.nz
Tue Feb 27 15:42:52 CST 2001


>     create table Links (
>            LinkID bigint(21) NOT NULL auto_increment,
>            Url varchar(255) NOT NULL,
>            LinkName varchar(64) NOT NULL,
>            Description varchar(255) NOT NULL,
>            PRIMARY KEY (LinkID),
>            UNIQUE (Url)
>            );
>
>     create table LinkCats (
>            LinkID bigint(21) NOT NULL,
>            CatID bigint(21) NOT NULL,
>            PRIMARY KEY (LinkID, CatID),
>            );

Hi Rudy,

This is probably going to sound really dumb, but why are there two 
PRIMARY KEYs in the second table? Won't that prevent multiple 
categories applying to the same LinkID? I'm working on something a 
bit similar, and am missing something here, because I would have 
thought that the LinkID would need to appear multiple times with each 
CatID that applied, and that the PRIMARY KEY is unique as well as 
primary.

Help?

Andrew
-- 
Andrew Forsberg
http://www.thepander.co.nz




More information about the thelist mailing list