Table Relationships

Okay, this is probably a dumb question, but…

What creates “table relationships” in MySQL?

I thought that if you create a PK in Table1 and a matching FK in Table 2 that a “relationship” would be implicitly created?!

Do you have to explicitly “create” table relationships for MySQL to know the relationships exist? :confused:

TomTees

in mysql (as with other databases), a relationship is created using FOREIGN KEY syntax

the only problem is, with MyISAM tables, the syntax is checked for correctness but then ignored, as foreign key relational integrity is not supported for MyISAM

what did you mean by “implicitly created”?

I am using a PHP book to brush up on PHP and learn how to create an e-commerce site. Since I didn’t create the examples, I am just “on the outside looking in” at what the author did (and trying to figure things out).

Yesterday, I made this post asking about CASE tools for MySQL so I could visually see how the author’s tables relate.

what did you mean by “implicitly created”?

I downloaded MySQL’s Workbench last night and there is a “reverse engineer” feature that is supposed to take an existing database with tables and generate an ERD.

When I did this I just got tables…

So this post was an attempt to understand why I wasn’t seeing “relationship” (lines) between the author’s tables.

(I assumed that if the tables had PK’s and FK’s, that Workbench would draw the relationship lines for me as well.)

My database background is mainly with MS Access, I used to more of the “hand-holding” that Microsoft provides with their Access GUI.

And I tend to be more visual, so it is easier for me to look at an ERD when I am reading chapters and trying to figure out the author’s Stored Procedures which are getting pretty complicated as they involve multiple joins.

Does that make sense?

Sincerely,

Tom Tees

i’d go looking for another tool at that point :slight_smile:

i agree with you about Access, it’s got some really excellent features