I'm designing a database for my new project. I'm wondering if my database design is correct as I'm not sure in 100%.
Users are allowed to add content: images, texts, URLs. Content will be listed on single page, so I think creating single content type will be the best choice.
So far, I have the following structure:
post
- id
- type ENUM
- title
- image NULL
- text NULL
- URL NULL
post_image
- id
- filesystem
- filename
post_text
- id
- body
post_url
- id
- link
Of course, I have 1:1 associations created for post tabke and post_* types tables. I use Doctrine as ORM in my application. To get content, I have a custom method that checks for type and returns correct content (text, URL or image path).
Is it the approach you'd recommend?
Two alternatives I have in my mind:
- creating nullable
image,textandurlfields in post table - creating a single
contentfield
While using the two above methods I get very simple and manintainable database structure, but this may cause some problems in the future.
Looking forward to hear some community voice.
Best!