Welcome Guest, Not a member yet? Register   Sign In
Need help modeling a very simple scenario with DataMapper ORM
#3

[eluser]Stolz[/eluser]
[quote author="WanWizard" date="1336593714"]First problem is in your relationship tables. Table names are combined in alphabetical order,...[/quote]

Thanks for pointing out that but acctually I was translating my code on the fly from Spanish to English and I forgot to rearrange the correct table names. In my orriginal code the alphabetical order is correct.

[quote author="WanWizard" date="1336593714"]As to your 'foo' question, ... a column called 'dishes_orders_id' suggests you have a model called 'dishes_orders' somewhere, but it's not in your list.[/quote]

Sorry again, another stupid typo mistake I made. Where it states 'dishes' instead it actually should state 'products'. So the right column name would be 'orders_products_id' and it should refer to the 'orders_products' table right above. I've just correted both mistakes in the original post.

The goal of the join fields is to store the price that the products had in the moment the relationship was created. In this way, if a 'product' or an 'extra' changes its price it won't affect the 'orders' made previously.

So the question is, what name should have the table 'foo' and how can I make my models aware of the relationship it represents?

[quote author="WanWizard" date="1336593714"]
And maybe a tip:

If you intent to work a lot with join fields, it might be worthwhile to look into breaking up your many to many relations, and make a model for the relationship table. This will allow you to query them via their model objects, instead of the quite complicated join fields construction.[/quote]
Thanks for the tip. I will consider your suggestion as soon as I understand the bascis of ORM. Right now I still didn't need to query anithing, I'm just learning the basics of modeling.

Thank you very much Wan for your help.


Messages In This Thread
Need help modeling a very simple scenario with DataMapper ORM - by El Forum - 05-09-2012, 03:52 PM



Theme © iAndrew 2016 - Forum software by © MyBB