laravel - Database Architecture: Multiple Type Relations -
i'm building laravel application has "listings". these listings can things boats, planes, , automobiles; each own specific fields.
i have images table should relate each type of listing , users table needs map each type of listing. i'm trying determine best way map each listing type images
, users
.
one way i've thought of doing having separate boats
, planes
, automobiles
tables specific fields , having specific boat_images
plane_images
, automobile_images
tables map each respective type. relating each type user bit tricky.
i don't think 1 giant listing table fields i'd ever use through these 3 (which grow in size later) make sense --- , don't believe having general metadata field has json object full of specifications each listing work either when want have searchable database.
i know of pivot tables, i'm trying grasp overall architecture here. appreciated. thanks!
you have listings
table, holding id
, name
. boats, planes, automobiles , others should subset table.
each table have own entity. , listing
entity have multiple hasmany
relationships subset tables. these relationships named boats()
, planes()
, etc. each subset listing entity hold single belongsto
relationship.
using these subset tables should compartmentalize form validation.
you can have single images
table , use polymorphic relationship towards listings table. 1 huge savior.
Comments
Post a Comment