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 simplyperform an equijoin, something like this:
SELECT Orders.ordernumber, Items.quantity, Items.partno FROM Orders, Items WHERE Orders.ordernumber = Items.ordernumber;