The project I have going uses multiple “walls” for discussion that are created by the user.
My question pertains to how this should be modelled in the MySQL database.
Would having one table called “walls” that contain the information such as who created it etc, and another table called “messages” that contain each message with a “wall_id” column to distinguish where it belongs, work?
Also, should the “messages” table use the wall_id as the primary key for indexing? Or is having duplicate numbers not useful for primary keying?
I am relatively new to modelling databases “the right way”, any suggestions or solid help is greatly appreciated for improving efficiency and ease of working with the data.
Your approach is indeed the correct way to go, except what you have said about the primary key. Primary keys have to be unique. You can have multiple fields as a primary key, but the key itself has to be unique.
So you would have the following tables.
You would then relate the
usertable onuser_idandwallonwall_id.