Changes between Version 13 and Version 14 of CompositePrimaryKeyDesignNotes
- Timestamp:
- Sep 1, 2012, 11:28:10 PM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CompositePrimaryKeyDesignNotes
v13 v14 4 4 5 5 == Design Questions == 6 ''How do you define multiple primary keys?''7 6 8 The "neatest" solution would be to allow primary_key=True on multiple fields but this may be precluded by other design considerations. 7 * ''How do you define multiple primary keys?'' 9 8 10 ''How do you foreign key onto a table with a composite foreign key?'' 9 The "neatest" solution would be to allow primary_key=True on multiple fields but this may be precluded by other design considerations. 11 10 12 ''What do you use for .get(pk=foo) with a composite primarykey?''11 * ''How do you foreign key onto a table with a composite foreign key?'' 13 12 14 The likely solution is to use a tuple or dictionary though there is mention of the comment framework overlapping with this.13 The primary key is a set of the columns. 15 14 16 ''How does Admin map a url to an object?''15 * ''What do you use for .get(pk=foo) with a composite primary key?'' 17 16 18 Should be able to be handled with some nice url escaping. 17 The primary key is a set of the columns. 18 19 The likely solution is to use a set, though there is mention of the comment framework overlapping with this. 20 21 * ''How does Admin map a url to an object?'' 22 23 Possible solutions (for a key with the value {{{ { val_foo, val_bar, val_baz } }}}: 24 25 * {{{/appname/modulename/val_foo,val_bar,val_baz/}}} 26 27 How to deal with values containing commas? Should be able to be handled with some nice url escaping. 28 29 * {{{/appname/modulename/val_foo/val_bar/val_baz/}}} 30 31 * ''The columns of a key are a set, and have no implicit order. How to deal with identity between different orders of the same set?'' 19 32 20 33 == Affected Areas == 21 34 22 35 === Models === 36 23 37 [wiki:CompositePrimaryKeyModelNotes On going in depth notes] 24 38 … … 32 46 33 47 === Queries === 48 34 49 Model.objects.get(pk=foo) needs to be supported. 50 51 Solution: the primary key is a set of the column values. 35 52 36 53 === Forms === 37 54 38 55 === Admin === 56 39 57 Expect there is a large amount of work in here making sure all the model inspection and form generation works. 40 58 … … 42 60 43 61 === Serialization === 62 44 63 Code needs to be looked at further but all the foreign keying is likely to need attention. 45 64 46 65 == Relevant Discussions == 66 47 67 * Jul 2008 http://groups.google.com/group/django-developers/browse_thread/thread/4b2370a0652d9135/2344ca721a4213fd (David Cramer initial thoughts) 48 68