Re: Database Relationship and Design Help
I thought I read somewhere that every table has to have an 'id' column in CakePHP. Anyway, I deleted the column and everything seems to be working fine still. I think I got it already. Thanks. On Feb 9, 10:40 pm, mscdex wrote: > Also, this is just a personal design decision but I would remove the > 'id' field on the join table and make both of the other two columns > primary keys. That enforces the rule (at the database level anyway) > that a member/comaker cannot be associated with the same loan multiple > times. --~--~-~--~~~---~--~~ 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: Database Relationship and Design Help
column "member_id" in ShortTermLoan is the id of the applicant. On Feb 9, 10:27 pm, mscdex wrote: > On Feb 9, 3:11 am, ramonmar...@gmail.com wrote: > > > > > Here is what I want it to be: > > Each member can apply for zero or more short term loan(s) > > A short term loan must have 1 or up to 3 comakers > > A comaker must also be a member. > > A member could be a comaker. > > It matters to know which member is the main 'loaner' and which member is > > the comaker for each loan. > > > Here is what the relationship looks like atm in my source: > > > Member $hasOne = array('ShortTermLoanComaker'); > > Member $hasMany = array('ShortTermLoan'); > > > ShortTermLoan $belongsTo = array('Member'); > > ShortTermLoan $hasAndBelongsToMany = array('ShortTermLoanComaker'); > > > ShortTermLoanComaker $belongsTo = array('Member'); > > ShortTermLoanComaker $hasAndBelongsToMany = array('ShortTermLoan'); > > That looks alright to me. To meet that last requirement, maybe you can > have a column in ShortTermLoan for the main "loaner" member ID and > force it to be non-null. Then of course all ShortTermLoanComakers > associated with that ShortTermLoan that do not have the ID contained > in that column, would be the comakers for the loan. --~--~-~--~~~---~--~~ 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: Database Relationship and Design Help
Also, this is just a personal design decision but I would remove the 'id' field on the join table and make both of the other two columns primary keys. That enforces the rule (at the database level anyway) that a member/comaker cannot be associated with the same loan multiple times. --~--~-~--~~~---~--~~ 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: Database Relationship and Design Help
On Feb 9, 3:11 am, ramonmar...@gmail.com wrote: > Here is what I want it to be: > Each member can apply for zero or more short term loan(s) > A short term loan must have 1 or up to 3 comakers > A comaker must also be a member. > A member could be a comaker. > It matters to know which member is the main 'loaner' and which member is > the comaker for each loan. > > Here is what the relationship looks like atm in my source: > > Member $hasOne = array('ShortTermLoanComaker'); > Member $hasMany = array('ShortTermLoan'); > > ShortTermLoan $belongsTo = array('Member'); > ShortTermLoan $hasAndBelongsToMany = array('ShortTermLoanComaker'); > > ShortTermLoanComaker $belongsTo = array('Member'); > ShortTermLoanComaker $hasAndBelongsToMany = array('ShortTermLoan'); That looks alright to me. To meet that last requirement, maybe you can have a column in ShortTermLoan for the main "loaner" member ID and force it to be non-null. Then of course all ShortTermLoanComakers associated with that ShortTermLoan that do not have the ID contained in that column, would be the comakers for the loan. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Database Relationship and Design Help
I'm have a problem on how I should 'design' my database for my current project. This is my current design: http://img264.imageshack.us/img264/4396/coopdbjx7.png (In the image it shows member_int, but the actual field name is member_id with a data type of int) Here is what I want it to be: Each member can apply for zero or more short term loan(s) A short term loan must have 1 or up to 3 comakers A comaker must also be a member. A member could be a comaker. It matters to know which member is the main 'loaner' and which member is the comaker for each loan. Here is what the relationship looks like atm in my source: Member $hasOne = array('ShortTermLoanComaker'); Member $hasMany = array('ShortTermLoan'); ShortTermLoan $belongsTo = array('Member'); ShortTermLoan $hasAndBelongsToMany = array('ShortTermLoanComaker'); ShortTermLoanComaker $belongsTo = array('Member'); ShortTermLoanComaker $hasAndBelongsToMany = array('ShortTermLoan'); I hope someone could help me with this. Thank you everyone. :D --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---