SQL question/puzzle
Posted in 1995
Topics: Triggers, Constraints & Referential Integrity
An SQL question/puzzle for the Net: Assume the following tables: STUFF (stuff_id, data....) stuff_id - unique ID for this record/tuple. data - the interesting part for a user. RELATE (stuff_id, co_nbr) stuff_id - foreign key into STUFF co_nbr - a valid company number for this STUFF record. STUFF one-to-many with RELATE. i.e, there can be several company numbers associated with a given STUFF record. (1-5) PERMIT (user_id, co_nbr_lo, co_nbr_hi) user_id - login ID for a user. co_nbr_lo - lowest company number for this range co_nbr_hi - highest company number for this range There will be many PERMIT records for the same user_id with different company number ranges. (5-20) Finally, the question: Given a user_id, how to find all STUFF records this user's company number ranges allows her access to? Would a different schema make this question easier to answer? - David dharper@neosoft.com