Code

Changes between Version 13 and Version 14 of CompositePrimaryKeyDesignNotes


Ignore:
Timestamp:
09/01/12 21:28:10 (20 months ago)
Author:
bignose
Comment:

discuss using a set for the primary key

Legend:

Unmodified
Added
Removed
Modified
  • CompositePrimaryKeyDesignNotes

    v13 v14  
    44 
    55== Design Questions == 
    6 ''How do you define multiple primary keys?'' 
    76 
    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?'' 
    98 
    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. 
    1110 
    12 ''What do you use for .get(pk=foo) with a composite primary key?'' 
     11* ''How do you foreign key onto a table with a composite foreign key?'' 
    1312 
    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. 
    1514 
    16 ''How does Admin map a url to an object?'' 
     15* ''What do you use for .get(pk=foo) with a composite primary key?'' 
    1716 
    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?'' 
    1932 
    2033== Affected Areas == 
    2134 
    2235=== Models === 
     36 
    2337[wiki:CompositePrimaryKeyModelNotes On going in depth notes] 
    2438 
     
    3246 
    3347=== Queries === 
     48 
    3449Model.objects.get(pk=foo) needs to be supported. 
     50 
     51Solution: the primary key is a set of the column values. 
    3552 
    3653=== Forms === 
    3754 
    3855=== Admin === 
     56 
    3957Expect there is a large amount of work in here making sure all the model inspection and form generation works. 
    4058 
     
    4260 
    4361=== Serialization === 
     62 
    4463Code needs to be looked at further but all the foreign keying is likely to need attention. 
    4564 
    4665== Relevant Discussions == 
     66 
    4767* Jul 2008 http://groups.google.com/group/django-developers/browse_thread/thread/4b2370a0652d9135/2344ca721a4213fd (David Cramer initial thoughts) 
    4868