SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist TomTees's Avatar
    Join Date
    Apr 2010
    Location
    Iowa
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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?


    TomTees

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,273
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    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"?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Evangelist TomTees's Avatar
    Join Date
    Apr 2010
    Location
    Iowa
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    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
    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

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,273
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by TomTees View Post
    When I did this I just got tables...
    i'd go looking for another tool at that point

    i agree with you about Access, it's got some really excellent features
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •