Foreign key refering to multiple tables


Problem:

I have 4 tables

A(ida, name)
B(ida, B-specific stuff)
C(ida, C-specific stuff)
D(ida, D-specific stuff)

and i want that another table E could refer to just B OR C (not D). What can i write in the

CREATE TABLE E

?


Solution:

Seems to me that you are trying to use some kind of supertype/subtype -- as opposed to simple vertical partitioning. If so, do introduce a type-discriminator.

Because this is generic example (A, B, C, D ..) it is hard to guess what relates to what, so here are two options as my best guess.


Option 1

enter image description here


Option 2

enter image description here

Recent Tips

  1. Run a visual studio 2010 Windows7 project on a Windows XP machine
  2. How to apply groupname to HTML radio buttons in asp.net?
  3. What is the most stable modal dialog implementation across browsers to use from javascript for a web app?
  4. Move, Remove, and Replace information from Google Sheets with new entries using Google Script
  5. How can I get rid of jerkiness in WinForms scrolling animation?
  6. Update MySQL table column from another table entities
  7. Shoot fireball once in unity C#
  8. Adding a table of contents to a Microsoft Word Document using vbs
  9. Change locale in android app (onto Hindi)
  10. How do I stop selenium automation if 20% or 1st 20 test cases test methods are failed?
  11. Sharepoint with silverlight app
  12. What's the best way to write robots.txt for github pages using multiple repos?
  13. Biopython: Cant use .count() for biopython
  14. How can I find out the token balance of an address?
  15. ref value is undefined in vue (modal, textarea, $refs)
  16. Azure - HDInsight Hbase Data Insertion Failed
  17. SignalR overwriting OnConnected(), OnDisconnected()
  18. DatePickerDialog displays with two borders
  19. "type 'double' is not a subtype of type 'int' in type cast" error in flutter. What should i do?
  20. hiding the autocomplete list when user click outside the textbox is not working as expected
  21. JSF IceFaces basic problem with redisplaying input value
  22. How to validate material ui TextField in reactjs?
  23. Go and MongoDB connection won't work with panic log "no reachable server"
  24. WordPress Posts Pagination Not Working
  25. F# sprintf won't print in interactive console
  26. Spring Integration get FTP files recursively with outbound-gateway
  27. Jade mixins not getting working from external file
  28. Can not access defined exports from the webpack bundle?
  29. Completely new to Node.js - API Programming
  30. Formatting Compare-Object Ouput