*The link between X and Info is redundant.* It is sufficient to have a link 
between X and Product. 

If you always want to get all Info-items as wel when retrieving the 
Product-items that belong to X, then you could eager load the Info entities 
together with the Product entities. 

It would probably become easier if you start thinking in entities instead 
of thinking about the foreign keys: that is only relevant for the mapping 
and the database. Otherwise you could as well use SQL and the database 
directly. Why would you then use an ORM? Better to build a good model 
first; forget about the database. That is for later. 


On Thursday, 20 March 2014 20:08:19 UTC+1, Parsifal wrote:
>
>  
> In tables "X", "Product" and  "Info"  I have a coloumn named "product_id", 
> this coloumn in table X is a simple coloumn but in both Product and Info 
> tables are primary key.
> In table X (where product_id is simple) I have:
> ManyToOne from X to Product cloumns/refenceColoumn => product_id 
> =>product_id
> ManyToOne from X to Info cloumns/refenceColoumn => product_id =>product_id
>  
> I understand when I want to add a new row to table X, first I should call 
> Product and Info entity by ->find() method as product_id can not be set 
> simply by:
> $this->productId = $blah
> nor cannot be null. but if I call these two entities, that would be 
> duplicate for productId in X entity.
> Now my question is that:
> Is it safe to have the same property like this as primary key in Product 
> and Info entities and X entity is mapped to these two as ManyToOne by that 
> property? Or better to have another coloumn in X table e.g. "something" and 
> join "something" coloumn to Info entity and product_id coloumn to Product 
> table, however the value of productId and Something in X table will be 
> always the same? Please advice if this is better to have a separate coloumn 
> in X for other two entities or this one I have is ok and I may ignore that 
> would be a duplicate productId? 
> I probably have to add that the relationship between Info and Product is 
> OneToOne as well.
> Look forward hearing from you as I am stuck in this.
>  
>  
>  
>  
>  
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to