well, with that naming convention we're going to hit the limit fast on the
name if a table has big column names.  can we name the foreign key
something random, like a hex string ?

Wade Leftwich wrote:
> Looks good. The index name has to be <= 64 chars, as does every MySQL
> identifier except an alias, which is <= 255.
>
> Note my correction on the syntax. It should be:
>
>  CREATE TABLE foo (
>      col1 integer primary key,
>       <colname> integer,
>       foreign key <fk>_<colname>_<remote_table_name>_<remote_colname>
> (<colname>) references <remote_table_name>(<remote_colname>)
>   ) engine=InnoDB
>
>
>
>
>
> Michael Bayer wrote:
>> OK, so we just do FORIEGN KEY
>> (<fk>_<colname>_<remote_table_name>_<remote_colname>) by default (field
>> names too long?), and maybe put an optional "name" field in the
>> ForeignKey
>> object, hows that ?
>>
>>
>> Wade Leftwich wrote:
>>
>>>Michael Bayer wrote:
>>>
>>>>Wade Leftwich wrote:
>>>>
>>>>
>>>>>For MySql 3.23.44 <= version < 4.1.2, the CREATE TABLE statement must
>>>>>explicitly name the foreign key indexes to be created, so as
>>>>> Sqlalchemy
>>>>>now stands the table.create() method will not work with an InnoDB
>>>>> table
>>>>>that has foreign keys.
>>>>
>>>>
>>>>
>>>>The syntax its doing right now is:
>>>>
>>>>CREATE TABLE foo (
>>>>    col1 integer primary key,
>>>>    col2 integer,
>>>>    foreign key (col2) references bar(col1)
>>>>) engine=InnoDB
>>>>
>>>>it works in my 5.0 installation.... 3/4 no good ?  we can make it
>>>>whatever
>>>>it has to be.
>>>>
>>>>
>>>
>>>For MySQL v < 3.23.44 -- forget it, foreign keys are not supported.
>>>For v >= 4.1.2, existing syntax is great.
>>>
>>>For 3.23.44 <= v < 4.1.2, I *think* you have to say
>>>CREATE TABLE foo (
>>>     col1 integer primary key,
>>>     col2 integer,
>>>     foreign key col2 (fk_col2_col1) references bar(col1)
>>> ) engine=InnoDB
>>>
>>>... where 'fk_col2_col1' is an index name, unique identifier in the DB.
>>>
>>>
>>
>>
>>
>
>



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to