Databse creation

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
janpan
Forum Newbie
Posts: 2
Joined: Fri Aug 05, 2011 12:09 pm

Databse creation

Post by janpan »

hi guys , I need to create a database to use with a website where users create/delete and share posts. I would like to know what do you think would be the best way to create the database.
E.g. There should probably be a db with a table for users , posts etc. and if so , how do I go about in linking the 2 , e.g. linking the user with his posts ?

I am writing the whole website from scratch and want to start of in the right direction.

T.I.A.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Databse creation

Post by social_experiment »

janpan wrote:how do I go about in linking the 2 , e.g. linking the user with his posts ?
Foreign keys. Simple example:
----------------------------------
user_tbl
----------------------------------
id, user_id, name

---------------------------------
post_tbl
---------------------------------
id, post_id, user_id

If a user makes a post, his id (user_id) is placed inside the post table.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
janpan
Forum Newbie
Posts: 2
Joined: Fri Aug 05, 2011 12:09 pm

Re: Databse creation

Post by janpan »

Awesome ! Helps a lot .

Thx
Post Reply