Hi, if anyone is brave enough to read this and offer me a few tips, I would appreciate it. Even though it is a drawn out question, I think once your read it you'll get the concept and immediately see what I can do to improve the speed of my queries. Ok, let's go!
I have about 30 companies that have a couple different type of forms submitted on their individual websites. Each time a form is submitted I trigger a phone call to their office so that they can talk with the customer immediately if they are present. If the call is connected, then I will also get more data from what actually transpired during that phone call. The data from the phone calls and forms go to my database. I have created the following tables with these configurations:
COMPANY TABLE
company_id (primary key), contact_name, contact_email, phone_number, address
CONTACT FORM TABLE
contact_form_id (primary key), company_id, visitor_name, email, subject, message, timestamp
SUPPORT FORM TABLE
support_form_id (primary key), company_id, visitor_name, email, problem, operating_system, application, error_message, message, timestamp
PHONE CALL TABLE
phone_call_id (primary key), company_id, form_id, form_type, number_dialed, time_call_started
PHONE CONVERSATION TABLE
phone_conversation_id (primary key), company_id, conversation_to_text, time_call_ended, call_duration
I would like to create a web page that will show a report of all the the phone calls with the phone information and also show the type of form (and it's info) associated with each phone call for that month. Right now I perform a query which joins the COMPANY TABLE with the PHONE CALL TABLE and the PHONE CONVERSATION TABLE. This gives me all the information about the company and phone calls, but now I also need the information from the forms. So what I do is grab the form_id in that first JOIN and during the query fetch loop, I do another query asking for the info from the form table. Here's some rough code to show you what I do:
select company_name, number_dialed, call_duration, conversation_to_text, form_id, form_type where COMPANY_TABLE.company_id = PHONE_CALL_TABLE. company_id AND COMPANY_TABLE. company_id = PHONE_CONVERSATION_TABLE. company_id
then from the fetch, I grab the form_id and form_type and do:
if( form_type == contact form )
select from CONTACT FORM TABLE where form_id = form id
else if( form_type == support form )
select from SUPPORT FORM TABLE where form_id = form id
Ok, done. Any way of optimizing this? I'm using MyISAM as the table type. This allows me to perform full text searches.
Thanks to anyone who can help.
b
select