Friday, January 21, 2011

Re: Question about foreign key conventions

Presumably the foreign keys are all keys to different tables ?

If this is the case then it is usual to name the key after the table it
references.

So table foo may contain...

bar_id ( reference to id field of table bar )
baz_id I reference to id field of table baz )

etc


On Fri, 2011-01-21 at 12:42 -0800, opike wrote:
> I have a table 'foo' that contains foreign key pointers to a table
> 'bar' in a 1 to many relationship, but the foreign keys are listed as
> columns:
>
> Table Foo:
> primary_key name bar_FK_1 bar_FK_2 bar_FK_3 bar_FK_4
> ------------------------------------------------------------------------------------------------------
> 1 A 10
> 11 12 13
> 2 B 20
> 21 22 23
>
> etc.etc.
>
> I want to restructure this table so that it best fits cakephp's
> default conventions.
>
> Should I redesign the table with 3 columns and break up each row into
> multiple rows? And if so,
> should I then call the foreign key column bar_id?
>


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: