I haven’t made my mind up yet, but am thinking that Articles on my website will follow this URL-structure…
[INDENT][COLOR="#0000FF"]w[B][/B]ww.mysite.com/finance/accounting/taxes/why-you-should-hire-a-cpa[/COLOR][/INDENT]
[INDENT][COLOR="#0000FF"]w[B][/B]ww.mysite.com/operations/manufacturing/production/is-just-in-time-the-way-to-go[/COLOR][/INDENT]
[INDENT][COLOR="#0000FF"]w[B][/B]ww.mysite.com/legal/type/litigation/does-suing-copyright-infringers-make-sense[/COLOR][/INDENT]
Here are the Entities and Relationships involved…
Entities:
- Category
- Dimension
- Sub-Category
- Article
Tables:
CATEGORY
- id
- name
DIMENSION
- id
- name
SUBCATEGORY
- id
- name
ARTICLE
- id
- slug
- author
- written_on
- heading
- body
Relationships:
CATEGORY -||-----|<- CATEGORY_DIMENSION ->|-------||- DIMENSION
DIMENSION -||----------|<- SUBCATEGORY
CATEGORY_DIMENSION -||-----------|<- SUBCATEGORY
SUBCATEGORY -||-----------|<- SUBCATEGORY_ARTICLE ->|------------||- ARTICLE
Questions:
1.) Is the second Relationship needed?
2.) For the CATEGORY_DIMENSION junction table, should I have a standalone Primary Key?
3.) For the CATEGORY_DIMENSION junction table, what should I use for my Foreign Keys?
-
category.id and dimension.id ??
-
category.name and dimension.name ??
4.) For SUBCATEGORY, what should I use for the Foreign Key to DIMENSION?
-
dimension.id ??
-
dimension.name ??
5.) For SUBCATEGORY, what should I use for the Foreign Key to CATEGORY_DIMENSION?
-
category.id and dimension.id ??
-
category.name and dimension.name ??
6.) For the SUBCATEGORY_ARTICLE junction table, should I have a standalone Primary Key?
7.) For the SUBCATEGORY_ARTICLE junction table, what should I use for my Foreign Keys?
-
category.id and dimension.id and sub-category.id and article.id ??
-
category.name and dimension.name and sub-category.name and article.slug ??
Over time, I always seem to change back and forth on which approach to take…
In closing…
-
Should Primary Keys always be an auto-increment Integer?
-
Can Primary Keys be a Text field when a Table is really just a Look-up Table? (e.g. Category, Dimension, Sub-Category)
-
And is it bad for Performance and Referential Integrity if you use Text fields for the Primary and Foreign Keys?
It appears there are several ways the above scenario could be handled, but I’m not sure what the BEST way is… :-/
Help needed!!!
Sincerely,
Debbie