Foreign keys and iterative tables
am 07.12.2005 20:18:11 von Joelle TegwenI'm new to MySQL and I'm trying to figure out some of the nuances of
foreign keys. I read section 14.2.6.4 of the users manual and I've read
a little about InnoDB (which we are using).
I'm working on migrating an Access database to MySQL.
For the most part it seems pretty straight forward. I just set up the
CONSTRAINTS as I would "relationships" in Access.
But then I came across a table that is iterative.
Section
----------
sectionID INT
parentID INT
Title VARCHAR
url VARCHAR
....
Where ParentID is the sectionID of another section *with the exception
of * the top tier sections. Those have a parentID of 0 and there isn't a
record with sectionID=0.
The documentation alluded to tables set up like this, but I'm not sure
how this works with foreign keys. Am I going to get an error? Does this
work? Am I misapplying this concept entirely?
Also, I'm interested in hearing anything you might want to say about
constraints, foreign keys and the like. (Flame wars aside) I'd love to
hear about your "constraint religion". :)
Links and references appreciated too.
Thanks in advance.
Joelle Tegwen
--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=gcdmw-win32@m.gmane.org