SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Table Relationships - Ms Access, - MySql?

    I am a Newbie to SQL and have been reading a whole lot about basic table relationships and have found it a little confusing when looking back and comparing it to Ms Access.

    Ms Access has a "Relationship GUI" and the help menu says .... "In most cases, you drag the primary key field (which is displayed in bold text) from one table to a similar field (often with the same name) called the foreign key in the other table."

    What does this Drag'n'Drop link in Access actually do behind the scenes that I need to do to Mysql to work?

    My understanding of table relationships is formed in two parts, Firstly the way the tables properties are set (eg Primary key /Foreign Key) and Secondly the SQL statement. Below is an example of my understanding for creating a simple relationship between two tables in Mysql.

    Create two tables, Customer and Orders.

    Customer table has
    CustID (Auto_increment, Primary Key)
    Name (Char)
    Email (Char)

    Orders table has
    OrderID (Auto_increment, Primary Key)
    Product (Char)
    CustID (Set as Foreign key)

    And thatís it ! The rest of the Relationship is in the form of the SQL query. (ie Inner Join, Left Join etc)

    Select Name
    From Customers
    Inner join Orders
    On Customers.CustID=Orders.CustID

    Is my above statement/thoughts/example correct ? Is this the BASIC PRINCIPLE ?

    If not, I would VERY much appreciate a BASIC 10-odd step guide to creating the relationship between two tables using MYSQL.

    I have visited the Mysql website however I still need clarification to my understanding of the BASIC table relationship principles.


    Thankyou to all.
    A
    Sometimes I get all confused !

  2. #2
    Yugo full of anvils bronze trophy hillsy's Avatar
    Join Date
    May 2001
    Location
    :noitacoL
    Posts
    1,859
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's the basic principle. The MS Access relationships window is just designed to confuse people who are trying to get their heads around relational architecture. I know it confused me, unitl I realised something...

    Always remember Access was intended as a GUI-driven desktop data-management tool. Not even a database, strictly speaking. So it sometimes represents ASCII/command-line concepts in ways that are confusing to people who are trying to use it at the server level (e.g. to drive a website). A great example of this is the "query builder". I've always found it much easier to just write straight SQL for Access queries - that tool is just confusing. But it's ideal for someone who doesn't know SQL.

    Defining a relationship "in" the database (i.e. in the relationships window) only has a couple of advantages in Access:

    - You can specify referential integrity constraints.
    - I personally find it a handy tool for mapping my database.
    that's me!
    Now A Pom. And a Plone Nut
    Broccoli Martinez Airpark

  3. #3
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear hillsy,
    I hoped I was on the right track.

    Thankyou very much for the response.

    BigA
    Sometimes I get all confused !


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
  •