doubledee — 2013-04-13T22:31:19-04:00 — #1
As stated in an earlier thread, I want to add the concept of "Sub-Sections" to my website.
Currently, I have articles just grouped by Section (e.g. Finance) which doesn't give me a lot of control with the UI or back-end. For example, I might have the diverse articles all lumped together under "Finance"...
...when they would be better groups like this....
So here is the data model that I have come up with...
[INDENT]One SECTION has one or more ARTICLEs
One ARTICLE has one or more SECTIONs
One SECTION has one or more SUB-SECTIONs
One SUB-SECTION has one or more ARTICLEs
One ARTICLE has one or more SUB-SECTIONs[/INDENT]
And using Crow's Foot Notation...
[INDENT](1) SECTION -||-----|<- SECTION_ARTICLE ->|------||- ARTICLE
(2) SECTION -||-----o|- SUB-SECTION
(3) SUB-SECTION -||-------|<- SUB-SECTION_ARTICLE ->|----------||- ARTICLE[/INDENT]
[INDENT]1.) To do things like validating URLs and storing data, do I need relationship #1?
(It seems like Relationship #1 and #3 are almost redundant?!)
2.) Do I just care about the end relationship between an Article and it's Sub-Section, or do I need to care about the relationship to the parent Section?
3.) Anything I need to take care of or should be concerned about?[/INDENT]
I just don't feel very confident in what I am doing here... :-/
r937 — 2013-04-14T07:02:15-04:00 — #2
1) only if you have articles that don't belong to a subsection
2) see 1)
3) retrofitting existing articles
doubledee — 2013-04-14T10:49:03-04:00 — #3
So it sounds like you approve of my Data Model and description above?? :-/
r937 — 2013-04-14T14:38:03-04:00 — #4
i guess so
i'd use only one table for sections and subsections, though
doubledee — 2013-04-14T16:18:26-04:00 — #5
Right now I have this...
SECTION -||-----|<- SUB-SECTION
r937 — 2013-04-14T16:41:13-04:00 — #6
because i like it, and i think it's more flexible
see Categories and Subcategories
jeff_mott — 2013-04-14T17:06:55-04:00 — #7
Thought I'd chime in to say that I agree with r937. Using just one table is more normalized and more flexible.
All you really need to do is add a field named something like parent_section_id to your table. Top-level sections will have a NULL parent section, and any sub-sections will have the parent section ID set appropriatly. This also makes it incredibly easy to create sub-sub-sections and sub-sub-sub-sections if ever you wanted to.
doubledee — 2013-04-14T17:22:18-04:00 — #8
I dunno. I started reading the link, and it sounds complicated. (Sorry, my brain is already overflowing trying to get this dumb website done?!)
You make some interesting points about scalability, though.
I'll look at it again after supper, and see if it sinks in more. :-/
P.S. I followed what r937 was doing with the first example, but I'm in a fog how to apply that to my website. (Remember, I am adding the concept of "Sub-Sections" to my website, which means I have to figure out how to re-tool my mod_rewrites and PHP and Queries...