On 13 January 2014 16:07, Dennis Fedco <[email protected]> wrote:

> Thanks.
>
> About simple sequential identifier:
>
> I have these tables:
>
>    - role(id, parent_id, name);
>    - action(id, controller_id, name);
>
> I understand you are proposing this table:
>
>    - role_has_action(sequential(id), unique_key(role, action,
>    controller));
>
>
Correct

> I suppose it will work, and I don't even see the need for a sequential ID,
> since the 3-tuple key will make entries unique, but then I see that this
> table is no longer tied to role, and action tables.  Hence, I am losing
> referential integrity.
>

Yes, you are, and you are also not having a fully normalized schema.
The problem here is that the ORM really puts a lot of effort in computing
identifiers, order of commits, extracting identifiers for associations and
so on.
While doctrine is a powerful ORM (even a rare one in PHP that supports
composite PK associations), don't just do things like this "just because
you can", because you will quickly hit the edge case: either in the ORM
choking because of this complexity or in performance (cpu wasted in
traversing derived identifiers).

Assuming that your identifier and unique key aren't allowed to change, you
will not have problems nor FK integrity issues.

Hope that helps - you are still free to go down the road of the composite
PKs, but it's easy to do something wrong and get some weird error that
isn't recognizable simply because the ORM itself can't recognize it in a
meaningful way :)

 Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

-- 
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/groups/opt_out.

Reply via email to