. It has been suggested that I create a separate table for every companyDidn't you misunderstand it? I think the idea is to create a separate table for all companies so each record of that table will belong to a single company then you just need to query the table.
Didn't you misunderstand it? I think the idea is to create a separate table for all companies so each record of that table will belong to a single company then you just need to query the table.
1 table with 15K records, 1 record per company/phone is just fine.
1 table for the orders, with a foreign key to the company.
Having separate tables per company will be a maintenance headache.
If each company can have one or many "shipping" addresses/phone numbers, a better option would be to have one table for all companies and their shipping addresses/phone numbers, placing a non-clustered index across the company and the phone number columns. This index would then allow any query against company and phone number to be relatively fast.
Hi Bob,
The problem that you're going to have is when you have queries that span multiple companies. That will have to be done with queries for each company.
At some point in the query a UNION ALL will have to be done, and depending on when that occurs performance will surely suffer.
It seems that partitioning the orders by company is probably what you want. It isolates the overhead of a query by a particular company so you get about the same performance as a separate table but allows you to produce multi-company queries with the same SQL as if you had a monolithic table.
Kent
No, this is not a good idea.
1 table with indices on the Company and Phone number fields should work fine in SQL Server.
But what is clearly being asked of me is to create a separate table for each company that stores the phone numbers and addresses for that order based on what company it is associated with.Run away from that "solution".
I think what you may be looking for a "Recipients" table, which describes who the shipment is going to. That table might have RecipientID, and details about the recipient.
Since each Recipient might have more than one phone #, then you might want a RecipientPhones table so that you can lookup the RecipientID when the user types in the phone number; this table would have RecipientID and Phone, maybe PhoneType and could have multiple values for each RecipientID, but would be unique across the RecipientID and Phone columns.
Then you would have a RecipientAddress table which would allow multiple shipping addresses for a particular RecipientID.
Use a physical analogy to explain this.
Would the office install a minimal number of file cabinets to hold 15,000 folders or would they buy 15,000 file cabinets?
The database works a lot like those file cabinets.
Victor,
I think Bob's initial description was confusing. I believe the phone# and Company are unrelated fields. The Company field is describing the delivery company. The phone number and address are describing the recipient.
SELECT DISTINCT PHone, Add_Street1, Add_Street2, Add_City, Add_State, Add_Zip
FROM Orders
If you put that into a new table, with an identity field, you could then store the identity field in the Orders table. This new table, indexed on Phone# would be a very fast search.
You should question them why. How they'll know which table is it? Then they need to build the query dynamically which means no use of cache and need to be compiled each time that the query will run.
Plus, they need to maintain more than 15K tables. Need to check if exist don't create. If not, create. And if in the future they need to add one more column? They need to add it in 15K tables!!!
They mentioned that tables can be "indexed", and therefore searching for them is not expensive at all.As company names, telephone numbers or addresses. So having the correct index set, searching a row in 15K rows should not be expensive at all.
What do you mean by "that got rejected"?
Rejected by "they"?
If none of the shipping companies overlap jurisdictions, then you might add the Company field to the PhoneAddress table and index by Company and Phone# (as was indicated early on). But I think that is overkill. You mentioned in one of your posts that you want some form of type-ahead feature in your application, is that correct?
The creation and maintenance of 15000 tables (I don't even know whether that is feasible) alone would be a nightmare.
Who is this "They" you keep talking about? Do they have any technical background at all?
Like Dale wrote: Do they have any technical background at all?
Unfortunately, most software developers have very little technical knowledge of how databases workPrecisely Dale. I've said this to them, and I was shot down as if I know nothing. I have done a reasonable amount of both web application design and database design, and the two are indeed two different animals with different overall methodologies and philosophies for managing information. So if they have no respect for my recommendations, then perhaps they will listen to a certified database expert in person (on their nickel). That's all I can do to prevent a potential disaster. It's going to be difficult to move forward with their plan knowing that I will eventually have to tear it down and rebuild it. But I'll just plan accordingly for that eventuality. Thanks again.
1 table with indices on the Company and Phone number fields should work fine in SQL Server.