Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL Server
Expertise: Beginner
Mar 25, 1997

Indexes in SQL

Question:
Is it possible to set indexes between tables in SQL expression?

Answer:
You can establish indexes on SQL tables, but SQL indexes do not create an implied relationship between tables. If you are familiar with PC databases like dBASE, SQL indexes are completely different — to indicate a relationship between tables in SQL, you need to use the syntax in the CREATE TABLE command that establishes PRIMARY and FOREIGN keys. If your SQL database does not support referential integrity (PRIMARY and FOREIGN keys), you will not be able to establish a formal relationship between two tables. Even without referential integrity, this does not keep you from treating two tables as if they are related. If you need to retrieve data from two logically related tables, you simply perform an equijoin, something like this:

        SELECT Orders.ordernumber, Items.quantity, Items.partno
                FROM Orders, Items
                WHERE Orders.ordernumber = Items.ordernumber;
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date