Possible to do a MySQL foreign key to one of two possible tables?

Well here’s my problem I have three tables; regions, countries, states. Countries can be inside of regions, states can be inside of regions. Regions are the top of the food chain.

Now I’m adding a popular_areas table with two columns; region_id and popular_place_id. Is it possible to make popular_place_id be a foreign key to either countries OR states. I’m probably going to have to add a popular_place_type column to determine whether the id is describing a country or state either way.

6 Answers
6

Leave a Comment