ScrollMaster Posted July 17, 2006 Share Posted July 17, 2006 MySql 5, PHP 5Hello, I am working on a forum system and I have a question to ask. I had tried mysqlfreaks but there forum system is down.I am working on generating all the posts for a thread.I have two tables, a table for users and a table for posts.I would like to know if it would be better to create a column with the userid and username in the post table so I do not have to make a call to the user table and extract that username that matches the userid. I think that creating a redundant column would be a waste of space in the database but having it there would make the query faster.So what do I do? Option 1: Make the Call to the user table to find the user name to save database space Option 2: Make a Redundant Column in the post table to save query time Option 3: Someone tells me of a magical way of making a call to both database in one query? Option 4: I write my code where it can access itself that the user table is so big that to make a call to it everytime for the posts is expensive and It should add that secound column to the post table.Which Option should I choose? Quote Link to comment https://forums.phpfreaks.com/topic/14893-better-to-create-a-redundant-column-or-make-a-second-call-to-the-database/ Share on other sites More sharing options...
king arthur Posted July 17, 2006 Share Posted July 17, 2006 I think you know the answer to your question. Putting redundant data in your posts table will create all kinds of problems and any speed increase will be negligible.You can retrieve the post and username in one query with a simple join something like "select posttable.post, usertable.userid from posttable, usertable where posttable.userid=usertable.userid". Quote Link to comment https://forums.phpfreaks.com/topic/14893-better-to-create-a-redundant-column-or-make-a-second-call-to-the-database/#findComment-59687 Share on other sites More sharing options...
fenway Posted July 18, 2006 Share Posted July 18, 2006 Agreed... multiple copies of any single piece of data is almost always bad (no always, though, but it this case, definitely). Flex the DB to its full potential, use JOINs, and it will all work out. Quote Link to comment https://forums.phpfreaks.com/topic/14893-better-to-create-a-redundant-column-or-make-a-second-call-to-the-database/#findComment-59828 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.