Better to Create a Redundant Column or Make a Second Call to the Database
Posted 17 July 2006 - 10:46 PM
Hello, 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?
Posted 17 July 2006 - 10:59 PM
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".
Posted 18 July 2006 - 07:57 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users