Your tables must be InnoDB, but otherwise, you can set up the keys using raw SQL code in phpmyadmin:

CREATE TABLE parent (id INT NOT NULL,
                     PRIMARY KEY (id)
) ENGINE=INNODB;
CREATE TABLE child (id INT, parent_id INT,
                    INDEX par_ind (parent_id),
                    FOREIGN KEY (parent_id) REFERENCES parent(id)
                      ON DELETE CASCADE
) ENGINE=INNODB;

look at the manual for more examples:
http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key- constraints.html

- Kevin

On Apr 20, 2007, at 2:31 PM, munene_uk wrote:

i know this is kinda not directly a flex question but i figure surely someone must use mysql in here for a flex app.....

anyway here goes.....

just a quick question....ive got a database of students and i want to somewhat design a relational database so that i can run relational queries. unfortunately i dont know how to construct foreign keys in mysql using phpmyadmin.

my idea was to have 4 tables namely

students
studentid
name
surname
address
etc
etc


enrolment
studentid      <----foreign key
courseid       <----foreign key

course
courseid
coursename

teachers
teacherid
teachername

the tables above are simplified and will probably contain much more data. my main prblem is that i dont know how to set up foreign keys within phpmyadmin so that i can keep my database relational.





Reply via email to