473,750 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Database Lookup Optimization and/or client-side validation alternative

Hi everyone. :-)

Our site gets a ton of traffic on our contact forms, which collect the
standard information (name, address, city, state, zip, home phone,
etc.) The form validation is done with PHP.

To eliminate (or at least deter) people wasting time submitting phony
information, we can compare the state to the zip code (one DB table)
and the zip code to the area code (another table in same DB).

I can use two select statements to compare the state to zip and zip to
area code (respectively), or I can manually create a solution so that
the lookups are done on the client side using JavaScript. If speed
won't be an issue, I prefer to do it using PHP/MySQL because that way
I only have to maintain the zip, state and area code data in the DB.

Having said all of that, below are two questions:

1. Will these simple lookups in each table take that long? To
reiterate: these forms are critical and must work fast. (FYI, there
are about 58,000 records in each table.)

2. Should I index certain fields, or perform some other MySQL admin
task(s) to help increase the speed of the lookups either now (before
implementation) or as regular maintenance?

The table that I use to compare zip to state has the following fields
(of which only the first two are used for what I am describing here):
zip varchar(5)
state char(2)
city varchar(35)
county varchar(35)
primary_city_co de int(1)
usps_code char(1)

The 2nd table that has only zip codes and area codes has the following
fields:
zip varchar(5)
area char(3)

I should mention that....

(1) I am an intermediate PHP programmer and beginning MySQL admin.

(2) My web host has PHPMyAdmin installed, which is what I use to
create and maintain the DB and its tables.

(3) Finally, I did pick up Mr. Dubois' MySQL book, although I need to
implement this solution in about 1 week, so I don't have time to
master MySQL without your help! :-)

Thanks for any/all tips to help me finish this project quickly! :-)
- Eric
Jul 19 '05 #1
2 3250
DCB
"Eric Linders" <el********@hot mail.com> wrote in message
news:49******** *************** **@posting.goog le.com...
Hi everyone. :-)

Our site gets a ton of traffic on our contact forms, which collect the
standard information (name, address, city, state, zip, home phone,
etc.) The form validation is done with PHP.

To eliminate (or at least deter) people wasting time submitting phony
information, we can compare the state to the zip code (one DB table)
and the zip code to the area code (another table in same DB).

I can use two select statements to compare the state to zip and zip to
area code (respectively), or I can manually create a solution so that
the lookups are done on the client side using JavaScript. If speed
won't be an issue, I prefer to do it using PHP/MySQL because that way
I only have to maintain the zip, state and area code data in the DB.

Having said all of that, below are two questions:

1. Will these simple lookups in each table take that long? To
reiterate: these forms are critical and must work fast. (FYI, there
are about 58,000 records in each table.)

2. Should I index certain fields, or perform some other MySQL admin
task(s) to help increase the speed of the lookups either now (before
implementation) or as regular maintenance?

[snipped]

Hello Eric,

I'd have thought the best approach would be to use both Javascript (client
side) and PHP / MySQL (server side). Reasoning:-

Assuming 90% of browsers have Javascript enabled, then you might logically
catch 90% of phony information without a lookup to the database. Thereby
speeding up corrections, and without creating uneccessary overhead.

The server side validation should still take place of course, to keep your
data clean.

Regarding your indexes, yes - they should be installed WHERE they are to be
used in your queries.
http://www.mysql.com/doc/en/MySQL_indexes.html
You can use EXPLAIN SELECT to optimize
http://www.mysql.com/doc/en/EXPLAIN.html

I hope that helps you.
D
Jul 19 '05 #2
DCB
"Eric Linders" <el********@hot mail.com> wrote in message
news:49******** *************** **@posting.goog le.com...
Hi everyone. :-)

Our site gets a ton of traffic on our contact forms, which collect the
standard information (name, address, city, state, zip, home phone,
etc.) The form validation is done with PHP.

To eliminate (or at least deter) people wasting time submitting phony
information, we can compare the state to the zip code (one DB table)
and the zip code to the area code (another table in same DB).

I can use two select statements to compare the state to zip and zip to
area code (respectively), or I can manually create a solution so that
the lookups are done on the client side using JavaScript. If speed
won't be an issue, I prefer to do it using PHP/MySQL because that way
I only have to maintain the zip, state and area code data in the DB.

Having said all of that, below are two questions:

1. Will these simple lookups in each table take that long? To
reiterate: these forms are critical and must work fast. (FYI, there
are about 58,000 records in each table.)

2. Should I index certain fields, or perform some other MySQL admin
task(s) to help increase the speed of the lookups either now (before
implementation) or as regular maintenance?

[snipped]

Hello Eric,

I'd have thought the best approach would be to use both Javascript (client
side) and PHP / MySQL (server side). Reasoning:-

Assuming 90% of browsers have Javascript enabled, then you might logically
catch 90% of phony information without a lookup to the database. Thereby
speeding up corrections, and without creating uneccessary overhead.

The server side validation should still take place of course, to keep your
data clean.

Regarding your indexes, yes - they should be installed WHERE they are to be
used in your queries.
http://www.mysql.com/doc/en/MySQL_indexes.html
You can use EXPLAIN SELECT to optimize
http://www.mysql.com/doc/en/EXPLAIN.html

I hope that helps you.
D
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2832
by: democratix | last post by:
Hi, I've only got a couple years experience developing for Access but have recently been experimenting with HTML/javascript for gui and client-side scripting, mysql for database and php for server-side scripting. I've been running it all on the development machine until the application I'm building is advanced enough to start optimising/testing with network lag in mind. So it's no slower, and in some ways at least it seems faster.
11
19030
by: John Collyer | last post by:
Hi, In assembly language you can use a lookup table to call functions. 1. Lookup function address in table 2. Call the function Like: CALL FUNCTION
3
3314
by: Nick L. | last post by:
All, This is a general question regarding how, and if, compiler optimization techniques affect the general concept of being able to update a component of an application without requiring a recompile of client code. For example, suppose I have component: common.dll which defines several constant values, say Const_A, Const_B and Const_C. Further say I have some client code in another component: client.dll which references common.dll and...
8
2037
by: Lucas Lemmens | last post by:
Dear pythonians, I've been reading/thinking about the famous function call speedup trick where you use a function in the local context to represent a "remoter" function to speed up the 'function lookup'. "This is especially usefull in a loop where you call the function a zillion time" they say. I think this is very odd behavior.
13
2534
by: John Baker | last post by:
Hi: I have a general question about table access and look ups. Over simplifying things,and using a very theoretical example, lets say I have two tables; Client and Bill. The client table has a unique auto number (which is indexed) and the Client name, as well as address and other key data
10
3814
by: junky_fellow | last post by:
what are lookup tables ? How can they be used to optimise the code ?
9
14276
by: TC | last post by:
I need to design a system which represents multiple "projects" in SQL Server. Each project has the same data model, but is independent of all others. My inclination is to use one database to store all projects. Looking at the numbers involved, however, I wonder if I would get better performance by storing each project in its own database. Suppose I have 50 projects, each with two users and 10,000 rows; it seems to me I'd rather have 50 x...
4
1483
by: Andrea Griffini | last post by:
Hello, I implemented that crazy idea and seems working... in its current hacked state can still pass the test suite (exluding the tests that don't like self generated output on stdout from python) and the stats after the quicktest are IMO impressing: LOAD_GLOBAL = 13666473 globals miss = 58988
30
5658
by: Neil | last post by:
Yikes! My database, which had been consistently 1 gig for a long time, went from being 1 gig to 3 gigs overnight! Looking at the nightly backups, the database increased on average about 5-15 MB per day, and was 1.06 GB on the Thursday night backup. Then, with the Friday night backup, it was 2.95 GB, and has stayed that way since! I did a Shrink on the database, but that didn't help the situation. The only thing I could think it might...
1
2593
by: DaveD | last post by:
Let's say I have a collection ("items") of objects that each have a "string Name" property. I understand I can create a loop like this: foreach (string name in names) { var item = (from x in items where name == x.Name select x).First(); // Work on item } Is there a way to make that query more efficient? (My assumption is
0
8838
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9577
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9339
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6804
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6081
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3322
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2804
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2225
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.