Monday, September 30, 2013

Re: How to relate table with one of many others?

Cake won't/can't but your code can make it happen.

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 30 Sep 2013, at 13:55:01, Kemal <ahmetkemalarik@gmail.com> wrote:

I am using Mysql Workbench and it forces plural names. I will fix them. Will cakephp decide whether it is a domain or a hosting looking by order_type_id?

On Monday, September 30, 2013 3:35:15 PM UTC+3, Jeremy Burns wrote:
Scrub that - I see there is an orders_id field on hostings and domains. Sorry. However, some of your fields have incorrect names:

  • domains->orders_id ought to be 'order_id'
  • hostings->orders_id ought to be 'order_id'
  • orders->orders_types_id ought to order_type_id
  • clients_bills table name ought to be client_bills
  • client_bills->clients_id ought to be client_id

I note that you have both clients_id and client_id on the orders table. I'm assuming that one would be the id used by the client? If so, the joining field will be order_id. I'd consider renaming orders_id to something that doesn't end in _id as Cake will try to find a related table and build an association with it; perhaps client_reference would be better?

If you made those changes you could get your basic models built using cake bake.

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 30 Sep 2013, at 13:23:25, Jeremy Burns | Class Outfit <jerem...@classoutfit.com> wrote:

Surely there would be a 1->many relationship between:
  • orders_types (which ought to be called order_types) and orders
  • domains to orders
  • hostings to orders?

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 30 Sep 2013, at 13:05:18, Kemal <ahmetke...@gmail.com> wrote:

Hello,

I have created a topic on stackoverflow but didn't get attention. So...

I am little confused about my db design. I have orders table that may have records from one of many others. So is it OK to relate each tables with 1:1 to orders. Please look at orders domains andhostings table relations.

My orders table rows has either a domain or hosting regarding to its orders_type value. There will be more than 10 products like domains, hostings etc. So creating a column on orders table for each product would not be a good practice.

What is the best way to build my structure for CakePhp?



--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+u...@googlegroups.com.
To post to this group, send email to cake...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+u...@googlegroups.com.
To post to this group, send email to cake...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate