Best method to verify multi-level relational dependencies

前端 未结 2 1004
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-06 05:31

Suppose you have entities A, B, C and D.

  • D relates to C
  • C relates to B
  • B relates to A

Furthermore, user is only allowed to <

2条回答
  •  走了就别回头了
    2021-01-06 06:06

    The obvious solution would be this: Given D, find C, then find B and eventually find A. If the chain breaks somewhere, access to D would be rejected. Unfortunately, this requires - if trivially implemented - 4 database accesses instead of just the one for A.

    I suppose that might be possible. It depends in part on what "relates to" means, but assuming a relatively straightforward schema, I'd expect you to be able to join all four tables in a single SQL statement. If part of the chain is missing, the query would return no rows.

    Or am I missing something?

提交回复
热议问题