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 designing a simple database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-26-10, 17:32
_db _db is offline
Registered User
 
Join Date: Mar 2010
Posts: 7
Help designing a simple database

First of all I'm a complete newb and I need help. I don't expect you to solve everything and am willing to make an effort.

I want to create a web page where I would track if a person was on a lecture or not. The HTML/CSS part is done, the PHP part will be, but the database part is what I don't know how to do.

This is what I need to do:

Person P1 attended lecture L1
Person P2 attended lecture L1
Person P3 attended lecture L1

Person P1 attended lecture L2
Person P2 attended lecture L2
...

There are about 20 persons, and exactly 15 lectures (L1-L15)

I created a table Lectures which has 2 fields LectureID (primary key) and LectureName. I also created a table Persons which has 5 fields, Person ID (primary key) and 4 others which describe that person.

I don't know how to "remember" the fact that a person was on a lecture. I definitely need to remember it so I can use it later.

Please help me
Reply With Quote
  #2 (permalink)  
Old 05-26-10, 22:13
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Code:
CREATE TABLE person_lectures 
( personID INTEGER NOT NULL
, lectureID INTEGER NOT NULL 
, PRIMARY KEY ( personID, lectureID )
, INDEX lecture_persons ( lectureID, personID )
, FOREIGN KEY ( personID ) REFERENCES persons ( personID )
, FOREIGN KEY ( lectureID ) REFERENCES lectures ( lectureID )
);

INSERT INTO person_lectures VALUES
 ( 1, 1 ) -- Person P1 attended lecture L1
,( 2, 1 ) -- Person P2 attended lecture L1
,( 3, 1 ) -- Person P3 attended lecture L1
,( 1, 2 ) -- Person P1 attended lecture L2
,( 2, 2 ) -- Person P2 attended lecture L2
;
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 05-27-10, 04:45
_db _db is offline
Registered User
 
Join Date: Mar 2010
Posts: 7
Great! Thanks a bunch!
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