Re: approaching a relational database
| From: | Doug Parker | Date: | Mon, 16 Dec 2002 17:23:37 +0000 |
| Subject: | Re: approaching a relational database | ||
| References: | 1 2 3 4 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-24182@lists.php.net to get a copy of this message | ||
Gotcha. thanks to everyone for the advice. I'm going to switch it to the 2 table format.
Thanks again,
Doug
David Eisenhart wrote:
I would go along the lines that Stas suggests. You appear to have a two table database here: Table1: tblHole hole_id, hole_no, course_id, par, WH, MH, Trees1, Trees2, Trees3 etc...------- -------- ---------- ---- ---- ---- ----- ------- ----- 1 1 1 2 2 1 3 3 1... ..18 18 1 19 1 2 20 2 2 21 3 2(Note the course_id field above acting as the foreign key to the table tblCourse) (You could make the hole_no, course_id pair of fields a unique index - afterall there should never be more than one entry for each hole_no, course_id pair) Table2: tblCourse: Course_id Course_Name State County---------- -------------- ----- ------- 1 xyz 2 abc... ...10 yyy(The use of course_id in your description below is good (you are thinking along the correct lines by introducing the foreign key field that references the course table) However, if I understand it correctly you are proposing to have a separate table for each hole attribute (1 table for par, 1 table for WH etc.. etc..) which is messy and unnecessary.) Good luck David Eisenhart "Doug Parker" <drparker@clam.rutgers.edu> wrote in message news:3DFDE875.E63CA03@clam.rutgers.edu...The grid for each course looks like this (excluding CourseName, State,County,Street, City, State)reallyHole1 | Hole2 | Hole 3 | ......... | Hole18 Par 9 4 7 .......... 6 WH 8 4 4 .......... 5 MH 5 4 4 .......... 5 Tees1 4 4 3 .......... 5 Tees2 3 3 2 .......... 5 Tees3 etc...Tees4 Tees5 For every course, I have to enter in all of these variables. It isn'tkeeping score, it's just a table of all the information for a givencourse -par, wh (women's handicap), mh, etc. What i did was pretty much make atablefor every row. Each table (par, for example) has a course_id that I setin thecourses table (that holds the CourseName, State, County, Street, City,State),and then 18 more fields - one for each hole. So it looks like: "par" table3course_id | Hole1 | Hole2 | Hole 3 | ......... | Hole18 165 4 4 5 ..........Is that alright? it was the most reasonable thing I could think of, buti'mnot too experienced in database design, so i figured i'd ask. Thanks, Doug