SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    Feb 2007
    Location
    Southern California
    Posts
    1,340
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Associated ids in different tables (Sitepoint db book)

    ? about page 88 in Sitepoint db book (c) 2004.

    The page shows two tables, joke and author. Is the joke table made in its entirety to generate the id numbers, then the author table is made in its entirety to generate its own id numbers, then you open the joke table again and create the authorid field? You would print out both tables and manually connect up the two?

    If this is so, and we want to create a web-based CMS, how do we add those id numbers in the CMS if the latest id number is not known? For instance, the last joke id may be 3,495 and we'll want to link it to author id 34. How is that done in CMS? You create a lookup table or drop-down list that returns all authors and the id? Or am I looking at this problem the wrong way?

    Thanks! I'm getting there!

    Steve H

  2. #2
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Steve,

    The question you're asking is covered in detail in Chapter 6 (A Content Management System).

    In brief, however, you're right: both the joke and author tables automatically generate IDs for new entries. Since each joke table entry includes a reference to an ID in the author table, however, the relevant entry in the author table must be created before you can create an entry in the joke table that references it.

    In Chapter 6, you'll create a form with a drop-down list populated with the names and IDs from the author table, which you can use to select an author while creating a new joke.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  3. #3
    SitePoint Wizard
    Join Date
    Feb 2007
    Location
    Southern California
    Posts
    1,340
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    OK, the joke.id and author.id are automatically generated. However, I would be typing in the joke.authorid numbers on my own. Got it.


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
  •