Search code examples
phplaraveldatabase-designmodelrelationship

Using a polymorphic relation to represent all pages on my website


I'm currenlty learning how to use Laravel by designing a Blog like website. I would like to use a polymorphic relationship to represent all page of the site then having a subtable "posts" containing all posts related data.

This is a picture representing my current database design (I have simplified the attributes)

database diagram

I'm not sure that it's the best approach to handle my data Can you give me some advices to improve my ideas ?

I have implemented my current database design but find it hard to update the post related page


Solution

  • Following IGala answer, having a type field is the correct way to handle inheritance in SQL.