Try going to www.mysql.com and search for "foreign key" in the
search box - I found 28 matches - here are the 1st 3 matches:
1. MySQL Manual | 5.4.5 Foreign Keys [4]
2. MySQL Manual | 5.4.5.1 Reasons NOT to Use Foreign Keys constraints [4]
3. MySQL Manual | 9.3.6 Using Foreign Keys [4]
That may be enough to get you going.
You definitely don't "need" to use foreign keys - and you
really can't use them with MySQL since they are not "really"
supported.
Faculty
Staff
Trouble
Trouble_actions
I prefer to give each table a numeric "key" - you'll have to
study the MySQL data types, but I like to use Integer
"auto_increment" fields for that. So,
Faculty - primary key faculty_id (auto_increment)
Staff - primary key staff_id (auto_increment)
Trouble - primary key trouble_id (auto_increment)
- columns for Trouble table will probably include
* faculty_id - if faculty could be involved
with Trouble ticket
* staff_id - if staff could be involved
with Trouble ticket
Trouble_actions - primary key trouble_action_id (auto_increment)
- one of the columns *must* be "trouble_id", so that
each trouble_action can be related to its
parent Trouble ticket.
- columns for Trouble table may include
* faculty_id - if faculty could be involved
with Trouble ticket action
* staff_id - if staff could be involved
with Trouble ticket action
Each table should include columns for the primary(?) key of the
other tables that it needs to relate to. An easy example is
the Company/Employee relationship - one table for Company, and
one table for Employee - the Employee table needs to have a
way to relate to the Company that the Employee works for, so
the Employee table would contain company_id, assuming company_id
is a key(probably primary key) in the Company table. This gets
you 2 things:
1. If you have a company, and want to find all employees
for that company, you can SELECT all the employees with
that company_id, and
2. If you have an employee, and want to know what company
that employee works for, you can use the company_id stored
in the Employee table to find the Company.
Pretty simple example, but hopefully it helps.
--
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com
Chris Toth [[EMAIL PROTECTED]] wrote:
>
>
> I'm having a extremely hard time grasping the concept of multiple tables. So
> far, I've been using just one table when designing a database. But now I
> have to design a database for a trouble-ticket system for our department.
> I've written out the design of the tables, but the part I don't understand
> is how the tables relate to each other. Do I need to use foreign keys? But
> if I do, I thought MySQL didn't support foreign keys?
>
> BTW, I've read most of the O'rielly mSQL/MySQL book and couldn't find my
> answers.
>
> Just in case it matters, I'm going to have one table full of faculty info,
> one of staff info, one for the trouble ticket itself, and possibly one for
> actions performed on the trouble ticket.
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php