I am stuck with database design of holiday package inventory project which contains a main table packages
for storing package information.
Here is the fields
One package may have many attractions and inclusions so that's why i choose a json
field.
So is this a slandered way or keep the attractions and inclusions in another table with foreign key relation??.
if i choose second method(ie different tables for attractions and inclusions) what about searching a package with particular attraction think that search requires a join query (Search with join is a bad practice??.).
But in the first method we can apply a json search (MySQL-version >5.7 supports json search).
It depends on how complex you foresee the project becoming. You can use your existing table configuration and leverage the JSON Search feature, however as your table gets bigger this will be a bigger and bigger problem for performance. It would be better to create 4 tables, Packages, Inclusions, Attractions and Relations.
Packages
Attractions
Inclusions
Relations
Then you can do joins to select any combination of the types and relate any number of them to eachother.
SELECT * FROM Packages p join Relation r ON p.ID = r.PID AND r.type = "Attraction" Left Join Attractions a ON a.ID = r.RID WHERE p.id = 1 /*specific package id*/