Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > General > Database Concepts & Design > Database Design

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-03-03, 17:02
nooch nooch is offline
Registered User
 
Join Date: Jun 2003
Location: Wakefield, UK
Posts: 8
Database Design

Database Design Quote | Reply

--------------------------------------------------------------------------------


I'm having difficulty linking some tables together. Basically the database is being hosted on MS SQL, but is still in design stage so any alterations can still be made. I need to link the following tables:


Students - This table holds information about the students attending a college. Each student is given a unique identifier.

Staff - Holds information about the staff, contains a unique identifier for each staff member

Assignments - Holds information about assignments, has unique identifier for each assignment.

Courses - Holds information about courses, has unique identifier for each course.

Progress - This holds information about each student's progress of each assignment. This is also used by the staff to mark assignments, and used by the college intranet to display to students which assignments are currently unfinished.

Now, many students can study on many courses. Many staff can teach on many courses. Each course contains many assignments.

Course=---=Students
Course=---=Staff
Course----=Assignments

Which is easy enough. However, the database is going to be used to create a more intricate information system, as part of mainly an ASP intranet system. So we need to some how add the progress table to the existing design so we can pull the following information from the database easily...

So from the database we need to:
  • display new assignments for students (if any) that staff submit
  • find out which course the student is studying, so we can direct the student to appropriate information
  • display student names for a staff member for individual courses that that they study on, as well as all courses
  • and also some other minor queries, but these are not majorly important.
If someone could suggest how we would go about relating the tables together to provide a solution that we can easily query and get the information above, we would really appreciate it, because we are stumped

Thanks in advance,

Daniel Thompson
Reply With Quote
  #2 (permalink)  
Old 06-04-03, 08:34
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 4,874
Re: Database Design

Really your database design should be based on how the data is actually related (I like your text colour change trick, I'll have to remember that!); examples of specific queries to be answered are not relevant at this stage (they may be relevant to adding indexes later).

So: what is the Progress entity about? It records the progress of a Student on an Assignment. This suggests:

Student -= Progress =- Assignment

Is there just ONE Progress record per Student/Assignment combination? If so, the key for Progress is (StudentID,AssignmentID). If not, you will need some additional attribute to distunguish records.
__________________
Tony Andrews
http://tonyandrews.blogspot.com
Reply With Quote
  #3 (permalink)  
Old 06-04-03, 20:38
nooch nooch is offline
Registered User
 
Join Date: Jun 2003
Location: Wakefield, UK
Posts: 8
yep you got it, the progress table records information about the the progress of students for each assignment.

And i think there is one record per student/assignment configuration, but it also needs taking into consideration that the staff have input on the progress, as they create the assignments and eventually mark them

Please find attached the origional relationship defined in MS access, so some of the relationships may be incorrect, please feel free to comment, and recommend any suggestions.

--Note Attachment is about 97k
Attached Images
File Type: jpg relationship.jpg (97.9 KB, 356 views)
Reply With Quote
  #4 (permalink)  
Old 06-07-03, 05:21
barryw barryw is offline
Registered User
 
Join Date: Apr 2003
Location: London, England
Posts: 38
I have created a Data Model that you might find interesting :-
http://www.databaseanswers.com/data_...ents/index.htm

There is a set of Business Rules that helps to clarify the conditions that the Database must satisfy if it becomes an operational system to record Student Assignments.

Barry Williams
Principal Consultant
Database Answers
Reply With Quote
  #5 (permalink)  
Old 06-10-03, 19:20
nooch nooch is offline
Registered User
 
Join Date: Jun 2003
Location: Wakefield, UK
Posts: 8
thanks.

OK i created a new layout i will explain as i go along, first i need some help with SQL, why won't the following code work:

Code:
CREATE TABLE Tutors( --Primary Key TutorID smallint NOT NULL PRIMARY KEY CLUSTERED IDENTITY(1,1), StaffTag char(11) NOT NULL, -- POSSIBILITY OF VALIDATION HERE Title varchar(10) NULL, Surname varchar(20) NOT NULL, Forename varchar(20) NOT NULL, IntTel varchar(8) NULL ) CREATE TABLE Courses( --Primary Key CourseID smallint NOT NULL PRIMARY KEY CLUSTERED IDENTITY(1,1), --Normal Fields FacultyID smallint NULL, -- Uncomment following two lines and customise to integrate with system -- FOREIGN KEY REFERENCES Faculty(FacultyID) -- ON DELETE NO ACTION CourseCode varchar(6) NOT NULL, CourseName varchar(50) NOT NULL, FTPT bit NULL ) CREATE TABLE TeachesOn( -- Primary Key RecordID smallint NOT NULL PRIMARY KEY CLUSTERED IDENTITY(1,1), --Foreign Keys TutorID smallint NOT NULL FOREIGN KEY REFERENCES Tutors(TutorID) ON DELETE CASCADE, CourseID smallint NOT NULL, FOREIGN KEY REFERENCES Courses(CourseID) ON DELETE CASCADE )

The error is:
Code:
Server: Msg 8139, Level 16, State 1, Line 31 Number of referencing columns in foreign key differs from number of referenced columns, table 'TeachesOn'.

i've looked for typos, but can't find anything, and as the tables it is referencing are created before i can't see there being a problem with this code? can anyone help me (again...)

Thanks in advance,

Danny
Reply With Quote
  #6 (permalink)  
Old 06-10-03, 19:29
nooch nooch is offline
Registered User
 
Join Date: Jun 2003
Location: Wakefield, UK
Posts: 8
Red face

...to answer my own question...

Code:
CourseID smallint NOT NULL, FOREIGN KEY REFERENCES Courses(CourseID) ON DELETE CASCADE

you'll notice the comma is in the wrong place

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

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