[EMAIL PROTECTED] wrote:
Hello,
I have two questions:
1. I have a table defined as follows ********************************************* create table MATABLE ( ID INTEGER not null, FK INTEGER not null, constraint PK_MATABLE primary key (ID) );
alter table MATABLE add constraint FK_MATABLE_REFERENCE_MATABLE foreign key (FK) references MATABLE (ID); ********************************************* I understand the FK reference the PK in the same table. My first question is can anybody give me a practical example of having the above architecture/relation. A sample of a few lines together with a short explanation would be great.
An employees table where one of the fields is the ID of that employee's manager. The manager is someone else (a different row) in the employees table.
2. The above script has been generated for Oracle. Can anyone tell me how to make it work for MySQL 4?
CREATE TABLE matable ( id INTEGER NOT NULL PRIMARY KEY, fk INTEGER NOT NULL, INDEX fk_idx (fk), FOREIGN KEY (fk) REFERENCES matable (id) )TYPE=InnoDB;
See the manual for the details <http://dev.mysql.com/doc/mysql/en/InnoDB_foreign_key_constraints.html>.
Thanks in advance,
Julien.
Michael
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]