QA


Q&A

Q1:

Can SQL be used to retrieve data from multiple database tables?

A1:

Yes. Although in this book we will be studying only examples that involve a single database table, commonly database tables share relationships. For example, imagine that we were working on a website for an eCommerce site, like Amazon.com. There might be a database table called Orders, which would contain a row for each order. Each order, of course, could have one or more items. Therefore, we might also have a table called OrderItems, which would contain a row for each item placed in each order.

These two tables obviously share a relationship with one another. That is, each row in the OrderItems table "belongs" to a particular row in the Orders table. This relationship can be expressed using foreign keys, which are special column types that relate a row in one table to a row in another. The topic of foreign keys is beyond the scope of this book.

After a relationship has been established between two tables, often you will want to retrieve results from both tables. For example, using the Orders and OrderItems example, we might want to issue a query that returns the list of orders placed in the past 24 hours. Along with each order, we might want to also retrieve its particular items. Such multitable SQL queries are beyond the scope of this book, but realize they are quite common in practice.

For more information on multitable relationships and more advanced SQL queries, consider picking up a copy of Sams Teach Yourself SQL in 24 Hours (ISBN: 0672324423).




Sams Teach Yourself ASP. NET 2.0 in 24 Hours, Complete Starter Kit
Sams Teach Yourself ASP.NET 2.0 in 24 Hours, Complete Starter Kit
ISBN: 0672327384
EAN: 2147483647
Year: 2004
Pages: 233

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net