User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 373,936 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,600 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:
Views: 342 | Replies: 0 | Solved
Reply
Join Date: Apr 2008
Posts: 1
Reputation: compsci is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
compsci compsci is offline Offline
Newbie Poster

Forum Threads Table Design

  #1  
Apr 10th, 2008
Hello all,

I am using MySQL version: 5.0.37

I am creating a forum. I am designing the tables for the threads and their replies and the relationship between them. Please have a look at these images and give me your thoughts. I have also included the schema.

http://i284.photobucket.com/albums/l...ableDesign.jpg
http://i284.photobucket.com/albums/l...ogicDesign.jpg

CREATE TABLE  Threads (
       threadID INT NOT NULL AUTO_INCREMENT
     , threadSubject VARCHAR(100) NOT NULL
     , threadContent TEXT NOT NULL
     , link VARCHAR(200)
     , poster VARCHAR(100) NOT NULL
     , PRIMARY KEY (threadID)
);

CREATE TABLE  ThreadReplies (
       replyID INT NOT NULL AUTO_INCREMENT
     , replySubject VARCHAR(100)
     , replyContent TEXT NOT NULL
     , poster VARCHAR(100) NOT NULL
     , PRIMARY KEY (replyID)
);

CREATE TABLE  ThreadsRepliesRelationship (
       threadID INT NOT NULL
     , replyID INT NOT NULL
     , INDEX (threadID)
     , CONSTRAINT ThreadsFK FOREIGN KEY (threadID)
                  REFERENCES  Threads (threadID) ON DELETE CASCADE
     , INDEX (replyID)
     , CONSTRAINT RepliesFK FOREIGN KEY (replyID)
                  REFERENCES  ThreadReplies (replyID) ON DELETE CASCADE
);

1) Is the on cascade correct, i have them in both tables? If a thread reply was deleted would it delete the actual thread - the first post?

Thanks all,
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MySQL Marketplace
Thread Tools Display Modes

Other Threads in the MySQL Forum

All times are GMT -4. The time now is 6:36 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC