[CDBI] Working with tables without primary keys?

Mark Schoonover schoon at amgt.com
Tue Nov 8 13:16:29 GMT 2005


Left to My Own Devices <mailto:nazareth at eye-of-newt.com> tapped at Monday,
November 07, 2005 7:13 PM:

> At 7:55 PM -0800 11/7/05, Mark Schoonover wrote:
>> Left to My Own Devices <mailto:nazareth at eye-of-newt.com> tapped at
>> Monday, November 07, 2005 6:49 PM: 
>> 
>>>>   > Given a table like this:
>>>>> 
>>>>>   +--------+----------+
>>>>>   | foo_id | foo_name |
>>>>>   +--------+----------+
>>>>>   |      0 | bar-1    |
>>>>>   |      8 | bar-2    |
>>>>>   |      3 | bar-3    |
>>>>>   |      8 | bar-4    |
>>>>>   |      7 | bar-5    |
>>>>>   |      4 | bar-6    |
>>>>>   |      7 | bar-7    |
>>>>>   |      4 | bar-8    |
>>>>>   |      0 | bar-9    |
>>>>>   +--------+----------+
>>>> 
>>>>  The primary key of that table seems to be (foo_id, foo_name).  At
>>>>  least there are no dupes in this sample data.  Just set that as
>>>>  your primary key.
>>> 
>>>  foo_name by itself is unique in this sample. If it's guaranteed to
>>>  be unique, you could use it as the key.
>> 
>> It doesn't look unique to me, there's two eights, and two sevens,
>> two fours, two zeros.... Three is the only unique number... You can
>> go to three, but should not stop unless going to four, unless three
>> is you final number, then you should throw the grenade...
> 
> You're looking at foo_id. I said that foo_name was unique.

Looks like I blew my first post to CDBI! My eye was drawn to the foo_id
because in my mind, that should be unique, not foo_name. Foo_name column
name doesn't convey any information that it's unique... I didn't look
closely at the data... Thanks for the clarification.

Mark




More information about the ClassDBI mailing list