BACKGROUND:
I am developing a search feature that enables users to search three entities at once: classes, student organizations, and events by name.
MySQL 5.6 and Innodb will be utilized on a relatively small server.
TABLES:
Search
entity_id (tiny_int)
entity_type (tiny_int)
full_name (varchar(255))
Index (Primary) -> entity_id, entity_type
Index (FULL TEXT INDEX) -> full_name
Class (entity_type = 1)
class_id
ALL OTHER COLUMNS...
Events (entity_type = 2)
event_id
ALL OTHER COLUMNS
Orgs (entity_type = 3)
org_id
ALL OTHER COLUMNS
QUESTION:
Is it appropriate to index the name of 3 seemingly similar but different data sets (class, event, organization) into one search table through the use of entity_id, entity_type
Primary Key?
How would I go about doing a join on the search table with the Class, Events, Orgs
tables? Is there a conditional I can do using the entity_type
?
Any help or guidance is greatly appreciated.