MySQL Forums :: Newbie :: Help with the best table layout for message board


Advanced Search

Help with the best table layout for message board
Posted by: Thor Strom ()
Date: November 28, 2009 04:54AM

I am currently working on a home project where I am developing a simple messaging board. For each post I need to have the IP address of the poster. What I am not sure is how the layout should be. What I have learned is to create a separate table (table 2) containing an IP ID (auto incrementing int), which the first table containing the posts points to (using foreign key), and a varchar (my choice for simplicity) for the IP addresses. Is this layout better than, say, just having a varchar as primary key in the second table or what about just having the varchar in the first table? What would be the most effective layout?

The reason that I want to have a separate table is that I also want a table containing banned IP addresses (table 3). If the first table contains the IP then I would have two tables containing IP addresses which are not linked, and I think this just looks ugly. If the second table only contains the varchar, then I have three tables all containing actual IP addresses but linked through the second table. This also seems like a weird layout. Bit if the second table contains a unique ID AND the IP address, then the table has two unique identifiers when I just really need one.

Could someone please show me the correct way of doing this?

Options: ReplyQuote


Subject Written By Posted
Help with the best table layout for message board Thor Strom 11/28/2009 04:54AM
Re: Help with the best table layout for message board Rick James 11/29/2009 03:31PM
Re: Help with the best table layout for message board Thor Strom 11/29/2009 06:01PM
Re: Help with the best table layout for message board Rick James 11/29/2009 06:14PM
Re: Help with the best table layout for message board Thor Strom 11/29/2009 06:18PM
Re: Help with the best table layout for message board Rick James 11/29/2009 06:31PM
Re: Help with the best table layout for message board Thor Strom 11/29/2009 06:47PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.