|
Posted by Rik on 10/24/06 15:02
Chung Leong wrote:
> Daz napisal(a):
>> I can't use any unique keys on my table, as each user can have 'up
>> to' 3600 items, and a row is added for each item the user has, in
>> the user table. For example:
>>
>> +-----+---------+
>>> uid | item_id |
>> +-----+---------+
>>> 3 | 1 |
>>> 3 | 3 |
>>> 3 | 5 |
>>> 3 | 6 |
>>> 3 | 7 |
>>> 3 | 9 |
>>> 3 | 12 |
>>> 3 | 13 |
>>> 3 | 15 |
>>> 3 | 16 |
>> +-----+---------+
>>
>> If a row doesn't exist, then a user doesn't own the item.
>
> I'm not terribly familiar with MySQL. I think it supports multi-column
> unique constraint. So in your case, you're force the uid + item_id
> combination to be unique.
Yup, and if it's about in ID that's in another table, the InnoDB engine
supports Foreign Key constraints.
Grtz,
--
Rik Wasmus
[Back to original message]
|