Not signed in (Sign In)
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthorsuthern
    • CommentTimeMar 27th 2008
     
    What would be the best method to create a small table with an PRIMARY index composed of three keys? I can of course create the table in Akelos without indexing and then use myPhpAdmin to add the three-column index, but I'd rather keep everything inside Akelos.

    Does Akelos support this?

    Thanks!
    •  
      CommentAuthorbermi
    • CommentTimeMar 27th 2008
     

    On your migration

    $this->createTable('products', 'id, price decimal(10.2) index, name, is_promoted, created_by');
    

    will automatically add indexes to boolean fields like is_index and to predictable foreign keys like created_by.

    You implicitly can select the fields to index by using the keys index or idx

    You also have an

    $this->addIndex()
    

    method

    ADOdb Data Dictionary syntax can also be used on your migrations.

    • CommentAuthorsuthern
    • CommentTimeMar 28th 2008 edited
     

    Thanks! I'm aware of the 'addIndex' function.

    My wording was unclear, sorry. What I meant to say was how do I create a COMPOUND index key, which contains three columns inside it.

    Reading through the ADOdb Data Dictionary link above it would appear that something like this should work (not tested)

    $this->createTable('products', 'key1 TINYINT index idx_cmp, key2 TINYINT index idx_cmp, key3 TINYINT index idx_cmp, created_by');
    

    But now if I use cloneRecord and any other Akelos active record functions, Akelos complains that it can't find the primary key column id. Does Akelos not handle Primary keys which are compound? Hmm. For now I'll work around it and add a regular 'id' key as the primary, but should that really be necessary? Food for thought.

    • CommentAuthorsuthern
    • CommentTimeMar 28th 2008 edited
     

    Ok, after much experimenting, why does not this work?

    $this->createTable('default_spots', array('columns' =>
             'id,'.
             'warehouse_id I2(1) NOTNULL INDEX idx_cmp,'.
             'spot_id I2(1) NOTNULL INDEX idx_cmp,'.
             'part_id I2(1) NOTNULL INDEX idx_cmp',
             )
         );
    

    When I do yadda yadda install, it creates a table with four indexes. One for each column. According to 'ADOdb Data Dictionary', the ability to define index's with the INDEX keyword was added in v4.94. Would someone care to try the point out why it does not create only two index's (one for id, and one compound)? Thanks!

Add your comments
    Username Password
  • Format comments as