3 | | Currently Django models only support single column primary keys. Support for multi-column primary keys would allow Django to better integrate with legacy databases (whose schema cannot be changed and have multi-column primary keys). There are a lot of details to get right here, but done right, it would allow for more flexibility in data modeling. |
| 3 | Relational database designs use a set of columns as the primary key for a table. When this set includes more than one column, it is known as a “composite” or “compound” primary key. (For more on the terminology, here is an [http://www.agiledata.org/essays/keys.html article discussing database keys]). |
| 4 | |
| 5 | Currently Django models only support single column primary keys, denying many designs where the natural primary key of a table is multiple columns. Django currently can't work with these schemas; they must instead introduce a redundant single-column key (a “surrogate” key), forcing applications to make arbitrary and otherwise-unnecessary choices about which key to use for the table in any given instance. |
| 6 | |
| 7 | This page discusses how to have Django support these composite primary keys. There are a lot of details to get right here, but done right, it would allow for more flexibility and potential simplicity in data modeling. |