android6011 Posted April 10, 2008 Share Posted April 10, 2008 I just want some feed back on these 3 tables, basically 1 is member info, one is article info, and one is comments about the articles. my only question as long as these look ok is, when i go to search for a comment based only article id, do i just do a WHERE commentid='articleid' ? Thanks CREATE TABLE members(memberid INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(memberid),username VARCHAR(15), password VARCHAR(50), datejoin VARCHAR(35), datelogin VARCHAR(35), privilege VARCHAR(20),profile MEDIUMTEXT) CREATE TABLE articles(articleid INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(articleid), memberid INT, Foreign Key (memberid) references members(memberid), datepost VARCHAR(35), article MEDIUMTEXT ) CREATE TABLE comments(commentid INT NOT NULL AUTO_INCREMENT, articleid INT NOT NULL, PRIMARY KEY(commentid,articleid), memberid INT, datepost VARCHAR(35), Foreign Key (memberid) references members(memberid, Foreign Key (articleid) references articles(articleid)) Quote Link to comment Share on other sites More sharing options...
AP81 Posted April 11, 2008 Share Posted April 11, 2008 That looks fine, but just remember that if you want Foreign Key support you need to have your table engine set to InnoDB, not MyISAM. MyISAM will accept the syntax for foerign key, but it won't actually enforce referential integrity. Someone please correct me if I am wrong. Quote Link to comment Share on other sites More sharing options...
android6011 Posted April 11, 2008 Author Share Posted April 11, 2008 ya i think you are correct, i just wanted to make sure my foreign and primary keys were ok since this is my first time messing with foreign keys. thanks 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.