My db structure is as below and I also have some data. How do I specify foreign keys using the MyIASM engine?
I have read the MySQL webisite, but because I am afraid of making errors I am asking you to show me an example.
- one article can belong to many categories.
- one article can have zero or many photos.
- one article ca开发者_StackOverflow中文版n have zero or many tags.
My db structure:
tb_categories|cat_id(pk) , catname , parent_id
tb_articles|article_id(pk) , title , subtitle , textbody , date , remark
tb_articles_categories|id(PK) article_id(fk) , cat_id(fk)
tb_phptos|photo_id(pk) , photofilename , article_id(fk)
tb_articles_photo|article_id(fk) , photo_id(fk)
tb_tags|tag_id(pk) , tagname
tb_articles_tags|id(PK) article_id(fk) , tag_id(fk)
MyISAM does not support foreign key constraints, so you don't.
MyISAM does not support foreign keys. Only InnoDB does.
精彩评论