sql - Can one table field link 2 additional tables? -


hello i'm student doing course in database oracle rdbms being used. have problem figuring out how implement section of eerd i'm hoping insight in. have attached diagram below.

the case blood bank. there 2 suppliers blood bank:

  1. donors give blood(identified id)
  2. other blood banks in area (identified id)

i want able track supplied particular parcel of blood in inventory. try assess leading field in inventory table referencing 2 fields in 2 different tables don't think possible unless advance concept haven't learned.

assumptions used creating eerd

  1. a donor donate multiple parcels of blood
  2. blood of varying types may supplied external blood banks in case of shortages
  3. customers (health centers) request blood taken inventory , recorded transaction
  4. transactions can reflect 1 customer
  5. a customer may perform multiple transactions
  6. a parcel of blood can reflected on 1 transaction
  7. a transaction reflect 1 parcel of blood
  8. in order distinguish between occasional , regular donors history of donations must maintained determine frequency of donations

view eerd here

field in inventory table referencing 2 fields in 2 different tables

while create 2 fks on top of same field, not want - such fk require both parent rows present, , need one present (and other absent).

while manually (in application code) implement "fk" can "choose" target (aka "generic" or "polymorphic" fk), not idea, reasons described here.

instead, create 2 separate null-able fields , 2 separate fks on top of them. make sure 1 of these fields null @ given time (through check constraint), make 1 of these fks "active". more info here.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -