On Wed, 2008-04-02 at 08:06 -0400, Chris wrote: > I've done this without questioning it ever since I can remember : no > matter what, assign a primary key to everything. > > Is this necessary when you have a ForeignKey relation? Can the > ForeignKey be the unique identifier in the table?
Yes, but... It clearly can't act as a many-to-one relation then, if you do that. It ends up acting as a one-to-one (since the primary key must be unique, so only one row in your table can refer to any particular row in the related table). However, there's nothing about relational databases that prevents a column from being unique, not null *and* referring to a row in another table. You can write ForeignKey(primary_key=True) in Django and will do what you expect. Regards, Malcolm -- Telepath required. You know where to apply... http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---