Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Jun 2006
    Posts
    5
    Member #
    13392
    Hi, I'm currently creating a tutorials page.

    I have 3 tables:
    1. Categories
    2. Topics
    3. Tutorials

    Here's an example of the layout
    Code:
    C++ - category
        Beginner - topic
            1.  Intro to C++ - tutorial
            2.  Hello World.
            3.  ...
        
        Intermediate
            ....
    Now, I'm trying to "link" these tables somehow. I haven't read any tutorials on combining or linking data from seperate tutorials, but I came up with the idea to store the id of the parent table like this:
    Code:
    Category Table
    id    title
    
    Topics Table
    id    categoryid    title
    
    Tutorial
    id    titleid        title        description        content        ...other stuff
    My question is if this is the right way to go about doing something like this or is there a better way of doing this?

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    That would be the correct way. Excpt I'm guessing `titleid' under `Tutorial' is `topicid'. Generally speaking, the naming convention is to name it `tablename_id'. This will give you free magic at a later date if you decide to use certain frameworks like Ruby on Rails or CakePHP.

    In the meantime, I'd suggest reading up on SQL JOIN statements, as they are precisely the way you'd combine these tables together. They're pretty awesome.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:00 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com