OK, so I think I'm beginning to understand.  So basically in my case I have a 
an item_id that I am using as the PK in the item table.  So I would 
substitute that where you are using pk, and I could use the same column in 
the category table to keep them in sync.  But I would need a new column for 
the primary key in the category table as the item_id would be repeated when 
one item is in multiple categories.

Levi "Consistency's Over-rated" Smith  (:

On Wednesday 17 August 2005 12:19 pm, Stewart Stremler wrote:
>
> Item (itm)
>   pk as int
>   description as varchar
>   . . .
>
> Category (cat)
>   pk as int
>   pkref as int
>   category as varchar
>
>
> To get all items in the OLD category:
>
> SELECT itm.pk, itm.description
>   FROM itm, cat
>  WHERE cat.category = 'OLD' AND itm.pk = cat.pkref
>
> To get a list of all categories:
>
> SELECT distinct category FROM cat
>
> Etc. etc.
>
> You don't _need_ foreign keys to make such references.  You might have a
> consistency issue in that if you remove a row from the Item table, you'll
> have stale data in the Category table, but that won't _hurt_ anything
> until you start reusing primary keys.
>
>
> -Stewart "Solve your problem with your tools at hand, improve it later"
> Stremler


-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to