Im focusing on my first frameworked website (using codeigniter) and getting trouble approaching with the easiest method to setup my database tables. This site is basically function just like a removed lower reddit and hackernews. Customers will register, produce a thread which has 2 possible cateogories and it has nested comments. To date Ive develop this setup:
id title password creationdate shortbio
id title content category creationdate
id parent id content creationdate
Now I am not sure how you can move from here. Would there be an easy method to create this up? Im getting probably the most trouble imagining the way the usernames connect towards the posts they create and in which the comments come up. Any help or direction is appreciated!!
The initial step you have to take is to determine the associations. An ERD (Entity Relationship Diagram) helps greatly within this. You may also make use of a tool like MySQL Work bench to attract the way the tables connect with eachother. It is extremely simple, it simply teaches you the associations involving the organizations. I'll list the most apparent ones here so you are aware how to begin
Comments fit in with Publish : Which means that your comments ought to table requires a publish_id column to keep the ID from the publish that's who owns this comment.
Posts fit in with User : Much like earlier, a person_id column in necessary for the posts table to designate possession.
Publish goes to Category : You've properly added a category column to designate possession.
After you have the associations planned out, you should use codeigniter to create your models akin to these primary organizations.
It will be helpful to include:
- status fields (tinyint) to tables, to have the ability to disable/enable publish, customers, comments.
- emails for customers
- shortbio is notsogood idea, easier to store bio pieces individually (birth date, surname, etc), so it will be more flexible
- for comments add publish_id, user_id fields - id of parent publish
- extract felines in separate table and link'em by cat_id (might be you'll finish using more than 2 felines)
id title status email password creationdate dob
id title status cat_id content category creationdate
id publish_id user_id parent_id status content creationdate
cat_id title status
More choices to add and improve will end up apparent throughout further development)