= Composite Primary Key Design Notes = Collating design considerations, options and decisions here to help get this feature moving. == Design Questions == '''How do you define multiple primary keys?''' The "neatest" solution would be to allow primary_key=True on multiple fields but this may be precluded by other design considerations. '''How do you foreign key onto a table with a composite foreign key?''' == Affected Areas == === Models === Need a way of defining the primary key. Generation of the create table SQL. A solution for foreign keying onto a table with a composite primary key. === Queries === Model.objects.get(pk=foo) needs to be supported, probably using a tuple or dictionary though there is mention of the comment framework overlapping with this. === Forms === === Admin === Expect there is a large amount of work in here making sure all the model inspection and form generation works. The other thing mentioned has been the url to object mapping which should be able to be handled with some nice url escaping. === Serialization === Code needs to be looked at further but all the foreign keying is likely to need attention. == Relevant Discussions == * Jul 2008 http://groups.google.com/group/django-developers/browse_thread/thread/4b2370a0652d9135/2344ca721a4213fd (David Cramer initial thoughts) * Sep 2008 http://groups.google.com/group/django-developers/browse_thread/thread/32f861c8bd5366a5/22732dc88e644f77 (David Cramer and Malcolm Tredinnick pk talk) * Nov 2008 http://groups.google.com/group/django-developers/browse_thread/thread/eac7c296c3797f5a/d94cd7cdd0d69b18 (David Cramer proposal) * Nov 2009 http://groups.google.com/group/django-developers/browse_thread/thread/eac31c483e6ef885/6e80505a789fa750