Results 1 to 5 of 5

Thread: Relational Databases...

  1. #1
    Registered
    Join Date
    Aug 2003
    Location
    Columbus, Ohio
    Posts
    122

    Relational Databases...

    Alright, I am about to start publishing articles and pages and author information. To create the DB relationships, do I need to do anything other than specifying corresponding fields in two tables...one an auto-increment, and the other a regular sm. integer field? Do I need to specify the relationship any other way...like through indexing or something?

    I have my tables set and stuff:

    Table[1] has two one-to-many relatinships. One to Table[2] and one to Table[3]

    But I'm not sure how to query them all to return the relevant data of all 3 tables. After I return the info, what does the resul set table look like? Any hints?

  2. #2
    Administrator Chris's Avatar
    Join Date
    Feb 2003
    Location
    East Lansing, MI USA
    Posts
    7,055
    You should set up indexes on anything you use in a where statement.

    There are many kinds of table joins. If I were you I'd pick up a nice SQL book. Not any specific database book but a book on SQL itself.

    Here is an example.

    Select *.author, *.article from articles, authors where author.id = article.author_id and article.id = '$article-id'
    Chris Beasley - My Guide to Building a Successful Website[size=1]
    Content Sites: ABCDFGHIJKLMNOP|Forums: ABCD EF|Ecommerce: Swords Knives

  3. #3
    Registered
    Join Date
    Aug 2003
    Location
    Columbus, Ohio
    Posts
    122
    Any suggestions on what book would be comprehensive and pretty much to the point? How would the result set be arranged for assignment variables in a my_sql_fetch_row()? I guess a start is knowing that the SQL part of this does the work rather than PHP...thanx...

  4. #4
    Registered GCT13's Avatar
    Join Date
    Aug 2003
    Location
    NYC
    Posts
    480
    Don't know about books, but here's some online SQL tutorials-
    http://sqlcourse2.com/
    http://www.sqlzoo.net/

    As far as retrieving the data using mysql_fetch_array, you can access the name of the column. For example, if you wanted to return column "cashflow" from your query:

    PHP Code:
    while ($row mysql_fetch_array($result)){
      echo 
    $row['cashflow'];

    ....

  5. #5
    Registered
    Join Date
    Aug 2003
    Location
    Columbus, Ohio
    Posts
    122
    http://sqlcourse2.com/ was exactly what I needed...thanx...

Similar Threads

  1. Windows Hosting from Hostony
    By Helen in forum The Marketplace
    Replies: 0
    Last Post: 05-10-2004, 06:38 AM
  2. More disk space, more bandwidth at the SAME PRICE!
    By Helen in forum The Marketplace
    Replies: 19
    Last Post: 04-26-2004, 10:59 AM
  3. Databases and SEO...
    By Stevens in forum Search Engine Optimization
    Replies: 2
    Last Post: 08-27-2003, 05:54 AM

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
  •