If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Help! on this simple Database design

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-06-11, 17:49
wontonnoodleboi wontonnoodleboi is offline
Registered User
 
Join Date: Jun 2011
Posts: 5
Help! on this simple Database design

I'm new to database design and I'd like to see if anyone can help me with this. The database will store comments/issues about projects so comments can be tracked and categorized.

Here's what I have so far. Please let me know if I am on the right track.

Tables: Comments/Issues(comment_id, type, date, priority_level), Project(project_name, location, date_started, date_ended), User(name, etc.), Submittal

- A project can have many comments/issues but a comment can only belong to one project.
- Each comment is assigned to one user or many users.
- A user can have many comments.

I'm having trouble with linking the tables together on the many to many relationship. Any help is very much appreciated. Thank you!
Reply With Quote
  #2 (permalink)  
Old 06-06-11, 18:41
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
can you explain more how a single comment can be associated with multiple users?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 06-06-11, 18:43
wontonnoodleboi wontonnoodleboi is offline
Registered User
 
Join Date: Jun 2011
Posts: 5
I'm sorry. Looking back at what I wrote I made a mistake. Each comment has one user that is in charge of it. So each comment would only have one user.
Reply With Quote
  #4 (permalink)  
Old 06-06-11, 18:45
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
okay [whew], that's reassuring

what's the submittal table for?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 06-06-11, 19:05
wontonnoodleboi wontonnoodleboi is offline
Registered User
 
Join Date: Jun 2011
Posts: 5
I was thinking there needed to be a table to link the project and comment tables.

Well here's the scenario and where I want to be at the end. A company needs to create a database to track comments on projects. Each comment submitted to the project belongs to a user that is in charge on it.

I'm a beginner and learning more on DB so let me know if I have missed anything. Thanks
Reply With Quote
  #6 (permalink)  
Old 06-06-11, 19:17
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by wontonnoodleboi View Post
I was thinking there needed to be a table to link the project and comment tables.
only if a single comment can apply to more than one project (which you already said was not the case)

here's what i think you can use --
Code:
CREATE TABLE projects
( id INTEGER NOT NULL PRIMARY KEY
, name VARCHAR(99) NOT NULL
, type VARCHAR(9) NOT NULL
, start_date DATE NOT NULL
, end_date DATE NULL
, priority SMALLINT NOT NULL
);

CREATE TABLE users
( id INTEGER NOT NULL PRIMARY KEY 
, name VARCHAR(99) NOT NULL
, iq SMALLINT NULL
);

CREATE TABLE comments
( id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT
, type VARCHAR(9) NOT NULL
, post_date DATE NULL
, priority SMALLINT NOT NULL
, project_id INTEGER NOT NULL
, user_id INTEGER NOT NULL
, CONSTRAINT valid_project
     FOREIGN KEY ( project_id ) 
        REFERENCES projects ( id )
, CONSTRAINT valid_user
     FOREIGN KEY ( user_id ) 
        REFERENCES users ( id )
);
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 06-08-11, 13:24
wontonnoodleboi wontonnoodleboi is offline
Registered User
 
Join Date: Jun 2011
Posts: 5
I've attached a drawing so hopefully the visual is better at describing this than me. I believe I might need the submittal table because the submittal table will be linked to the comments where it can be parsed to each project. So each project has many comments. I believe this would be a many to many relationship?


Thanks again for the help.
Attached Thumbnails
Help! on this simple Database design-capturedb.png  
Reply With Quote
  #8 (permalink)  
Old 06-08-11, 13:37
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by wontonnoodleboi View Post
So each project has many comments. I believe this would be a many to many relationship?
no, only if a single comment can apply to more than one project -- which i point out once again you already said wasn't the case

so it's one-to-many, not many-to-many -- each project has multiple comments, but each comment applies to only one project
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #9 (permalink)  
Old 06-08-11, 13:43
wontonnoodleboi wontonnoodleboi is offline
Registered User
 
Join Date: Jun 2011
Posts: 5
If you look at my diagram, would I need a submittal table and a comment table?
Reply With Quote
  #10 (permalink)  
Old 06-08-11, 13:57
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
your diagram does nothing for me, sorry

i still don't think you need a "submittal" table -- how is that going to be different from the comment table?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On