Hello forums!!
I am in dilema regarding DB design, so I am expecting the forumians help here.
I have 3-4 tables(say categories, brands, products, etc.) and each table has images.
I would like to design db for images for all those tables.
1> My first Approach:
----------------
category_images
----------------
- id
- category_id
- image_title
- image_path
- is_active
- ordering
----------------
----------------
brand_images
----------------
- id
- brand_id
- image_title
- image_path
- is_active
- ordering
----------------
----------------
product_images
----------------
- id
- product_id
- image_title
- image_path
- is_active
- ordering
----------------
Note: all the table have similar structure
2> 2nd Approach
(wordpress like taxonomy concept)
------------------
taxonomy_images
------------------
- id
- taxonomy
- object_id
- image_title
- image_path
- is_active
- ordering
------------------
where,
taxonomy = category or brand or product
object_id = category_id or brand_id or product_id
And query is done as:
[HIGHLIGHT="MySQL"]SELECT * FROM taxonomy_images WHERE taxonomy=? AND object_id=? ORDER BY ordering[/HIGHLIGHT]
I want opinions from you to choose the appropriate design (for long run)
or can suggest some alternatives too.
Thanks