i have a table called orders. one column on order is customer_id
i have a table called customers with 10 fields
Given the two options if i want to build up an array of order objects and embedded in an order object is a customer object i have two choices.
Option 1:
a. first query orders table. b. loop through records and query the persons table to get the records for the person
This would be something like:
Select * from Applications a, Customers c
Innerjoin c.id = a.customerID
Option 2:
a. do a join on all fields
its an obvious #2 because you are only doing one query versus 1 + [numberOforders] queries (could be hundreds or more)
this would be something like:
Select * from APplications
Select * from Customer where id = 1
Select * from Customer where id = 2
Select * from Customer where id = 3
Select * from Customer where id = etc . . .
my main question is, what if i had 10 other tables that were off of the orders table (similar to customer) where you had the id in the order table. should you do a single query that joins these 10 tables or at some point is it inefficient do to this:
any suggestions would help.. is there any optimization to ensure fast performance