Re: Constants in hasAndBelongsToMany relationship.

2010-11-16 Thread kura
Hi John,

Thanks for your reply!!

It was very helpful and I got the idea now.
I understand that having those constants in a table is totally fine as
the database design.

Yes, the payment method in my case could be added in the future, so
this time I'll take the classifiers table approach.

Thank you very much again for your help!!

Kura



On 11月14日, 午後7:19, John Andersen  wrote:
> Consider your future requirements regarding payments - could there in
> the future be other kinds of payment methods that you would like to
> include?
>
> If the answer to that is No, then go for another solution, like having
> each payment method as a logical field in your seminar table.
>
> If the answer to that is Yes, then go for the table. Usually what I
> do, when I have several small sets of classification records, is to
> create one table to hold them all, like this:
>
> classifiers:
> id int
> name varchar(20) // Name, ex. CASH, CREDITCARD.
> classifier_id int
>
> Using your example, the records would be:
> id, name, classifier_id
> 1, PAYMENT METHOD, null
> 2, CASH, 1
> 3, CREDITCARD, null
> 4, BANK TRANSFER, null
> etc.
>
> Thus your example becomes:
>
> Seminar HABTM Classifier
> OtherModel HABTM Classifier
> etc.
>
> Hope you get the idea, enjoy,
>    John
>
> On 14 Nov., 08:29, kura  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > This may be a very basic question, but I've been struggling with a
> > design problem in hasAndBelongsToMany relationship.
>
> > I have a "Seminar" model that represents seminar information, and each
> > of the seminar can have many payment methods like in Cash, CreditCard,
> > Bank Transfer, etc.
>
> > I have defined the "PaymentMethod" definitions in bootstrap.php as
> > follows:
>
> > Configure::write('PaymentMethod.Cash', 1);
> > Configure::write('PaymentMethod.CreditCard', 2);
> > Configure::write('PaymentMethod.BankTransfer', 3);
> > ...
>
> > As the seminars can have many payment methods, and each payment method
> > can have many seminars that uses it, the relationship between
> > "Seminar" and "PaymentMethod" models is "Has And Belongs To Many
> > (HABTM)".
>
> > If I want to use the CakePHP HABTM relationship functionality, it
> > seems that I need to have a database table for the PaymentMethod
> >constantsas well as the Seminars and the join table
> > seminars_payment_methods.
>
> > In this case, should I create a table for the "PaymentMethod" and
> > insert those constant data, instead of defining in the
> > Configure::write() method?
>
> > I don't feel it's a good design to create a table just for the
> >constantsthat may never be modified in the app. There could be a lof
> > of these cases, so I might have to have SO MANY of the tables that
> > holsconstants...
>
> > What is the best practice in this case?
>
> > Thanks for your help in advance.

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Constants in hasAndBelongsToMany relationship.

2010-11-14 Thread John Andersen
Consider your future requirements regarding payments - could there in
the future be other kinds of payment methods that you would like to
include?

If the answer to that is No, then go for another solution, like having
each payment method as a logical field in your seminar table.

If the answer to that is Yes, then go for the table. Usually what I
do, when I have several small sets of classification records, is to
create one table to hold them all, like this:

classifiers:
id int
name varchar(20) // Name, ex. CASH, CREDITCARD.
classifier_id int

Using your example, the records would be:
id, name, classifier_id
1, PAYMENT METHOD, null
2, CASH, 1
3, CREDITCARD, null
4, BANK TRANSFER, null
etc.

Thus your example becomes:

Seminar HABTM Classifier
OtherModel HABTM Classifier
etc.

Hope you get the idea, enjoy,
   John

On 14 Nov., 08:29, kura  wrote:
> Hi,
>
> This may be a very basic question, but I've been struggling with a
> design problem in hasAndBelongsToMany relationship.
>
> I have a "Seminar" model that represents seminar information, and each
> of the seminar can have many payment methods like in Cash, CreditCard,
> Bank Transfer, etc.
>
> I have defined the "PaymentMethod" definitions in bootstrap.php as
> follows:
>
> Configure::write('PaymentMethod.Cash', 1);
> Configure::write('PaymentMethod.CreditCard', 2);
> Configure::write('PaymentMethod.BankTransfer', 3);
> ...
>
> As the seminars can have many payment methods, and each payment method
> can have many seminars that uses it, the relationship between
> "Seminar" and "PaymentMethod" models is "Has And Belongs To Many
> (HABTM)".
>
> If I want to use the CakePHP HABTM relationship functionality, it
> seems that I need to have a database table for the PaymentMethod
> constants as well as the Seminars and the join table
> seminars_payment_methods.
>
> In this case, should I create a table for the "PaymentMethod" and
> insert those constant data, instead of defining in the
> Configure::write() method?
>
> I don't feel it's a good design to create a table just for the
> constants that may never be modified in the app. There could be a lof
> of these cases, so I might have to have SO MANY of the tables that
> hols constants...
>
> What is the best practice in this case?
>
> Thanks for your help in advance.

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Constants in hasAndBelongsToMany relationship.

2010-11-13 Thread kura
Hi,

This may be a very basic question, but I've been struggling with a
design problem in hasAndBelongsToMany relationship.

I have a "Seminar" model that represents seminar information, and each
of the seminar can have many payment methods like in Cash, CreditCard,
Bank Transfer, etc.

I have defined the "PaymentMethod" definitions in bootstrap.php as
follows:

Configure::write('PaymentMethod.Cash', 1);
Configure::write('PaymentMethod.CreditCard', 2);
Configure::write('PaymentMethod.BankTransfer', 3);
...

As the seminars can have many payment methods, and each payment method
can have many seminars that uses it, the relationship between
"Seminar" and "PaymentMethod" models is "Has And Belongs To Many
(HABTM)".

If I want to use the CakePHP HABTM relationship functionality, it
seems that I need to have a database table for the PaymentMethod
constants as well as the Seminars and the join table
seminars_payment_methods.

In this case, should I create a table for the "PaymentMethod" and
insert those constant data, instead of defining in the
Configure::write() method?

I don't feel it's a good design to create a table just for the
constants that may never be modified in the app. There could be a lof
of these cases, so I might have to have SO MANY of the tables that
hols constants...

What is the best practice in this case?

Thanks for your help in advance.

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en