View Full Version : Relational Databases...
Stevens
02-03-2004, 01:04 PM
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?
Chris
02-03-2004, 01:16 PM
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'
Stevens
02-03-2004, 01:23 PM
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...
GCT13
02-03-2004, 01:45 PM
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:
while ($row = mysql_fetch_array($result)){
echo $row['cashflow'];
}
Stevens
02-04-2004, 11:07 AM
http://sqlcourse2.com/ was exactly what I needed...thanx...
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.