Re: Foreign Keys definition in Schemas

2008-10-03 Thread mark_story

Yes you can define additional indexes in the indexes key.  However,
you will not be able to force innodb foreign key with references, as
this feature is not supported in all databases it was not implemented
in the schema system.

On Oct 2, 8:00 pm, luissquall <[EMAIL PROTECTED]> wrote:
> I cannot find a way to define foreign keys in CakeSchemas. I suppose
> it should be inside 'indexes' key, but is it possible?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Foreign keys

2007-07-05 Thread Giulio Simeone



 Ketan Patel

> The problem is the foreignKeys. You do not have
> the foreignKey
> constraint satisfied and that's why MySql is
> complaining. ForeignKeys
> means that for that value, you have the entry in the > foreign Table.

Hi Ketan,
thanks for your kind reply.

However, let me explain the problem more accurately: this error seem
to occur with every record I try to put in the table, even with those
record that satisfy the costraints.

The record I'm trying to insert satisfies all the costraints, as I
checked over and over; however, the error occurs, and it occurs even
when I remove from the query the fields that are foreign keys.

The query is like that

INSERT INTO Books (ID_Book, ID_Author, ID_Nation,ID_Publisher) VALUES
(32,27,101,4)

and in the foreign tables there are an author with ID 27,a nation with
ID 101, and a publisher with ID 4. All the constraints seem to be
satisfied, but the error occurs.

Do you have any suggestion?

Thank you in advance!



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Foreign keys

2007-07-05 Thread Ketan Patel


Giulio Simeone wrote:
> Hello,
> when I try to insert a new record in a certain table I get the error
>
> Cannot add or update a child row: a foreign key constraint fails
>
> The table has three foreign keys and six other fields, but this error
> appairs with every record I try to insert in the table, even if I
> don't give any values to the foreign keys.
>
> What can be the problem?

The problem is the foreignKeys. You do not have the foreignKey
constraint satisfied and that's why MySql is complaining. ForeignKeys
means that for that value, you have the entry in the foreign Table.

If you have table "Posts" in which you define category_id as the
foreign key then, the value of category_id must be present in id field
of category table.

Cheers,
Ketan ;-)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Foreign Keys and Cake Naming Conventions

2007-04-03 Thread GreyCells

As you have stated above, you only need to create a link table for
many-to-many relationships. If your table is joining to eight other
tables and they are one-to-one or many-to-one relationships, then the
table will simply have eight foreign keys.

'Link' tables should not be that common, it should often be a full
entity with other attributes (other than the two foreign keys) so
becomes part of many-to-one and one-to-many relationship with the
other two tables. In the unlikely event you really have a schema that
requires eight link tables off one table, you should perhaps revisit
your design - I work with schemas that have tens of thousands of
tables/views and cannot think of a true 'link' table amongst them.

HTH

GreyCells

On Apr 3, 3:18 am, "uk_maul" <[EMAIL PROTECTED]> wrote:
> Here is an example of what I was trying to ask:
>
> many-to-many join tables should be named:
> alphabetically_first_table_plural_alphabetically_second_table_plural
> ie: tags_users
>
> So if my table is joining to 8 other tables, with the 8 foreign keys,
> how do I get the table name? Will it just be the first fk join table
> that I will put in the name and ignore the others?
>
> Thanks
>
> On Apr 2, 7:21 pm, "uk_maul" <[EMAIL PROTECTED]> wrote:
>
> > Hi
>
> > I am new to CakePHP and need some help with the Cake database naming
> > conventions. Our ERD has over a 100 tables (its almost fully
> > normalized). Most tables have one or two foreign key relationships
> > with other tables, so we followed the Cake conventions fine for those
> > and named all the tables in plural and with underscores between the
> > related tables. There are a few tables however that have as many as 6
> > or 8 foreign keys. I would like to know how to follow the Cake naming
> > conventions for those tables and how can we set up the relationships
> > for those tables in the models and how it will impact the automagic
> > database functions that depend on the naming conventions.
>
> > Thanks in advance for help with this.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Foreign Keys and Cake Naming Conventions

2007-04-02 Thread [EMAIL PROTECTED]

It's hard to give advice without knowing what sort of a schema you
have in place. Giving a layout would help.


On Apr 2, 10:18 pm, "uk_maul" <[EMAIL PROTECTED]> wrote:
> Here is an example of what I was trying to ask:
>
> many-to-many join tables should be named:
> alphabetically_first_table_plural_alphabetically_second_table_plural
> ie: tags_users
>
> So if my table is joining to 8 other tables, with the 8 foreign keys,
> how do I get the table name? Will it just be the first fk join table
> that I will put in the name and ignore the others?
>
> Thanks
>
> On Apr 2, 7:21 pm, "uk_maul" <[EMAIL PROTECTED]> wrote:
>
> > Hi
>
> > I am new to CakePHP and need some help with the Cake database naming
> > conventions. Our ERD has over a 100 tables (its almost fully
> > normalized). Most tables have one or two foreign key relationships
> > with other tables, so we followed the Cake conventions fine for those
> > and named all the tables in plural and with underscores between the
> > related tables. There are a few tables however that have as many as 6
> > or 8 foreign keys. I would like to know how to follow the Cake naming
> > conventions for those tables and how can we set up the relationships
> > for those tables in the models and how it will impact the automagic
> > database functions that depend on the naming conventions.
>
> > Thanks in advance for help with this.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Foreign Keys and Cake Naming Conventions

2007-04-02 Thread uk_maul

Here is an example of what I was trying to ask:

many-to-many join tables should be named:
alphabetically_first_table_plural_alphabetically_second_table_plural
ie: tags_users

So if my table is joining to 8 other tables, with the 8 foreign keys,
how do I get the table name? Will it just be the first fk join table
that I will put in the name and ignore the others?

Thanks

On Apr 2, 7:21 pm, "uk_maul" <[EMAIL PROTECTED]> wrote:
> Hi
>
> I am new to CakePHP and need some help with the Cake database naming
> conventions. Our ERD has over a 100 tables (its almost fully
> normalized). Most tables have one or two foreign key relationships
> with other tables, so we followed the Cake conventions fine for those
> and named all the tables in plural and with underscores between the
> related tables. There are a few tables however that have as many as 6
> or 8 foreign keys. I would like to know how to follow the Cake naming
> conventions for those tables and how can we set up the relationships
> for those tables in the models and how it will impact the automagic
> database functions that depend on the naming conventions.
>
> Thanks in advance for help with this.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Foreign Keys and Cake Naming Conventions

2007-04-02 Thread [EMAIL PROTECTED]

http://manual.cakephp.org/appendix/conventions

Foreign keys should not affect the naming of a table. Nor would the
number of keys affect the naming of the table or of the fields.

Foreign keys, ideally, should be the name of the model + underscore +
'id'
So multiple foreign keys should not affect each other.

Maybe you forgot to tell us about some part of the scenario, but so
far everything you have stated is pretty normal, and very well covered
in the manual.

regards,
cook


On Apr 2, 11:51 am, "gwoo" <[EMAIL PROTECTED]> wrote:
> tables = plural (posts)
> jointables = alphabetic, (posts_tags)
> foreignKey = singular _id (post_id)
> model = singular (Post)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Foreign Keys and Cake Naming Conventions

2007-04-02 Thread gwoo

tables = plural (posts)
jointables = alphabetic, (posts_tags)
foreignKey = singular _id (post_id)
model = singular (Post)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---