redmarine Posted March 11, 2011 Share Posted March 11, 2011 My goal is to create a blog like site that sorts blog posts (entry) by ID, however, what puzzles me is how I should go about storing messages, as well as the posters ID, for each of my blog posts. How should I do this in the database table? This is the basic structure of my table so far, figured it would be dumb to make the whole thing if I'd have to rework it all: CREATE TABLE `database`.`blog post` ( `id` INT NOT NULL AUTO_INCREMENT , `title` VARCHAR( 100 ) NOT NULL , PRIMARY KEY ( `id` ) ) ENGINE = MYISAM ; Anyhow, how would I go about creating a new column that could store all posts+user ids? Would it require linking two or more tables together? I'm running my database on MySQL client version 5.0.7 Advices or links to tutorials/threads that would solve my issue would be appreciated! Quote Link to comment Share on other sites More sharing options...
TOA Posted March 11, 2011 Share Posted March 11, 2011 Google it, i found several that can answer your question. Then come back and we'll help you Quote Link to comment Share on other sites More sharing options...
fenway Posted March 11, 2011 Share Posted March 11, 2011 Google it, i found several that can answer your question. Then come back and we'll help you That's not very helpful. What's the purpose of this new column? Quote Link to comment Share on other sites More sharing options...
TOA Posted March 11, 2011 Share Posted March 11, 2011 Google it, i found several that can answer your question. Then come back and we'll help you That's not very helpful. My apologies if it came off that I was being mean or abrupt; but the rules even say to try something yourself before asking for help. The fact that a google search found his answer is not me being unhelpful, I pointed him in the right direction. (Something you've done to me a few times ) Quote Link to comment Share on other sites More sharing options...
redmarine Posted March 11, 2011 Author Share Posted March 11, 2011 Google it, i found several that can answer your question. Then come back and we'll help you That's not very helpful. My apologies if it came off that I was being mean or abrupt; but the rules even say to try something yourself before asking for help. The fact that a google search found his answer is not me being unhelpful, I pointed him in the right direction. (Something you've done to me a few times ) Well, as you can probably tell English isn't my native language so I'm pretty pathetic when it comes to searching for technical stuff on the internet, even more so that I'm 1 month into this whole database and table thing. Google it, i found several that can answer your question. Then come back and we'll help you That's not very helpful. What's the purpose of this new column? It's more a question of how I should store the comments that will be posted on the blog. Since I'm pretty new to this whole database and table thing I'm still trying to figure out the possibilities as well as the limitations of them. What I thought was possible was to perhaps add a new column to the table for storing comments, however, I can't seem to store more than just a single comment. Would you know how I should go about handling this? I'm open for entirely different solutions if my idea is broken. Quote Link to comment Share on other sites More sharing options...
TOA Posted March 12, 2011 Share Posted March 12, 2011 Look into normalization. It's a big topic, so don't get discouraged, but focus on relationships and primary/foreign keys. I'll whip up an example for you in the meantime Quote Link to comment Share on other sites More sharing options...
fenway Posted March 12, 2011 Share Posted March 12, 2011 Google it, i found several that can answer your question. Then come back and we'll help you That's not very helpful. My apologies if it came off that I was being mean or abrupt; but the rules even say to try something yourself before asking for help. The fact that a google search found his answer is not me being unhelpful, I pointed him in the right direction. (Something you've done to me a few times ) At the very least, some URLs might have helped. Quote Link to comment Share on other sites More sharing options...
redmarine Posted March 12, 2011 Author Share Posted March 12, 2011 As DevilsAdvocate mentioned, normalization appears to be quite a big factor when it comes to designing tables so I'm probably going to study them for a bit and do more research into what makes a database. I didn't know that making databases was this complex but it appears to be fun enough to try out. I'll periodically check this thread, in the next couple of days, about any additional tips you guys may have for me on how to solve my particular problem. Anyhow, thanks for your help so far. Quote Link to comment Share on other sites More sharing options...
TOA Posted March 12, 2011 Share Posted March 12, 2011 Google it, i found several that can answer your question. Then come back and we'll help you That's not very helpful. My apologies if it came off that I was being mean or abrupt; but the rules even say to try something yourself before asking for help. The fact that a google search found his answer is not me being unhelpful, I pointed him in the right direction. (Something you've done to me a few times ) At the very least, some URLs might have helped. Ok, I'll give you that As DevilsAdvocate mentioned, normalization appears to be quite a big factor when it comes to designing tables so I'm probably going to study them for a bit and do more research into what makes a database. I didn't know that making databases was this complex but it appears to be fun enough to try out. I'll periodically check this thread, in the next couple of days, about any additional tips you guys may have for me on how to solve my particular problem. Anyhow, thanks for your help so far. The big thing is understanding when and why. Related info should be stored in like tables. So for your use, you would have a User table and a comment table. Each would have a unique ID (the primary key). The Comments table would hold the User Primary key in it as the foriegn key, linking the comment to the user. That way, if something changes in the user table, it doesn't need to in the comments table and the other way around. Let us know if you run into any snags Quote Link to comment 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.