Following is what I want to achieve, any clues on how to achieve the following in Django orm and mysql without composite key support from django Any workarounds, any one is aware of.
thanks copying straight from http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html For MyISAM and BDB tables you can specify AUTO_INCREMENT on a secondary column in a multiple-column index. In this case, the generated value for the AUTO_INCREMENT column is calculated as MAX(auto_increment_column) + 1 WHERE prefix=given-prefix. This is useful when you want to put data into ordered groups. CREATE TABLE animals ( grp ENUM('fish','mammal','bird') NOT NULL, id MEDIUMINT NOT NULL AUTO_INCREMENT, name CHAR(30) NOT NULL, PRIMARY KEY (grp,id) ); INSERT INTO animals (grp,name) VALUES ('mammal','dog'),('mammal','cat'), ('bird','penguin'),('fish','lax'),('mammal','whale'), ('bird','ostrich'); SELECT * FROM animals ORDER BY grp,id; Which returns: +--------+----+---------+ | grp | id | name | +--------+----+---------+ | fish | 1 | lax | | mammal | 1 | dog | | mammal | 2 | cat | | mammal | 3 | whale | | bird | 1 | penguin | | bird | 2 | ostrich | +--------+----+---------+ On Aug 31, 6:21 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Sun, Aug 31, 2008 at 2:05 PM, ydjango <[EMAIL PROTECTED]> wrote: > > > How to implement following create table (mysql) using django model. > > > CREATE TABLE account_transaction ( > > account_id INT NOT NULL, > > acct_trans_number INT NOT NULL AUTO_INCREMENT, > > PRIMARY KEY (account_id,acct_trans_number) > > ); > > > The above is mysql script. Acct_trans_number has to be unique and > > sequential within an account id. > > this the only way it can be achieved in mysql as far as I am aware. > > > How to do it using Django models? > > You cannot (currently) get Django to generate a CREATE TABLE that looks like > that, Django currently does not support composite primary keys. See: > > http://code.djangoproject.com/ticket/373 > > which near the end has a pointer to the latest discussion regarding adding > this feature. > > Karen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---

