Jump to content

[SOLVED] how does this look?


android6011

Recommended Posts

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))

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.