Hi Jeremy, Thanks for your link will definitely look into that.

~~Continue my question~~
I was going to ask about using this: http://book.cakephp.org/view/1027/query

There are 2 options if I'm correct based on cookbook 1.3
~~
Rather than using an auto-increment key as the primary key, you may
also use char(36). Cake will then use a unique 36 character uuid
(String::uuid) whenever you save a new record using the Model::save
method.

according to: http://book.cakephp.org/view/903/Model-and-Database-Conventions
~~
What's the advantage of using char(36) ?
~~

On Dec 27, 7:18 pm, Jeremy Burns | Class Outfit
<[email protected]> wrote:
> I would always have a non-inteligent single field as the primary key (id) and 
> then have a multiple field unique index on the other two fields. I'd also 
> index them independently for joins and performance. Your second solution 
> looks closest and it's also the way Cake works. 
> Seehttp://articles.classoutfit.com/2010/02/cakephp-basic-database-table-...
>
> Jeremy Burns
> Class Outfit
>
> [email protected]http://www.classoutfit.com
>
> On 27 Dec 2010, at 07:33, John Maxim wrote:
>
> > Hi everyone,
>
> > I'm currently creating a table called "Foods_Ingredients", here is the
> > sql:
>
> > CREATE TABLE IF NOT EXISTS `foods_ingredients` (
> > `food_id` int(11) NOT NULL AUTO_INCREMENT,
> > `ingredient_id` int(11) NOT NULL AUTO_INCREMENT,
> > PRIMARY KEY (`food_id`,`ingredient_id`)
> > ) ENGINE=InnoDB
>
> > ------------------------------
> > The problem now  is I find this table has to have composite primary
> > key. Cake currently doesn't support composite, I'm not sure what is
> > the workaround for this.
>
> > 1. Do I change to UNIQUE KEY ? I went briefly with the cookbook,
> > finding it hard to understand, can anyone suggest a solution for
> > this ?
>
> > 2. Do I just add a field `id` into it ?--so it becomes the PK? Adding
> > this seems a bit odd.
> > --------------------------------
> > CREATE TABLE IF NOT EXISTS `foods_ingredients` (
> > `id` int(11) NOT NULL AUTO_INCREMENT,
> > `food_id` int(11) NOT NULL,
> > `ingredient_id` int(11) NOT NULL,
> > PRIMARY KEY (`id`),
> > UNIQUE KEY `food_id_ingredient_id` (`food_id`,`ingredient_id`)
> > ) ENGINE=InnoDB
> > ------------------------------------
>
> > What is the suggested solution for this ? from veterans/experienced
> > Cake users.
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups 
> > "CakePHP" 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 
> > athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" 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/cake-php?hl=en

Reply via email to