Folks,
My internet access is intermitent until I get my own connection inside
the next ten days - I say this so that I can thank in advance who ever
gives a few seconds to read/answer my query...
Basically - I have three columns in my table... product name hash,
product tax code and a unique numeric record id.
A product can contain one or more taxes hence this table is a
relationship table that will
1) allow me to search all taxes for a single product or
2) all products that are tied to a specific tax
and I will use the unique numeric id if I want to delete one or more of
the taxes tied to a single product.
My question:
Should I have keys/indexes for each of the columns? Is it one of those
questions that is best answered with six of one and half a dozen of the
other? I believe in this case because the table is so small and likely
only to contain a couple of thousand records at maximum, it would be
unhealthy to have indexes as maintaining them would create a bit of an
overhead. What though, if the table were to contain a larger amount of
records (say, in the millions) but retain the same number of columns -
what would be the best advice in this case?
I'd be grateful for a reply to the newsgroup (so all can learn) and I'll
find somewhere to read the reply over the next days.
Much appreciated,
Randell D. 3 1664
Randell D. wrote: Should I have keys/indexes for each of the columns?
If you want to search data from the table and use certain column to
identify which rows should be returned, then that column should have
index, unless you think that having index causes too slow inserts or
takes too much hard drive space. In normal situations slow inserts and
hard drive space are not issues.
Also, normally searches in one table are quite fast and last under 0
seconds with less than 10 000 rows. Search in multiple tables with joins
can be hours or 0 seconds, depending on whether you have indexes or not
on the columns you are using in search.
According to your specifications: 1) allow me to search all taxes for a single product or 2) all products that are tied to a specific tax
You need to have two indexes in that table. One for product id and one
for tax id.
>Basically - I have three columns in my table... product name hash, product tax code and a unique numeric record id.
If you want the database to enforce uniqueness on the record id
(e.g. it's an auto_increment), you need a unique index on that
column.
Is (product name hash, product tax code) unique? Although a product
can have more than one tax and a tax can have more than one product,
can the SAME product have the SAME tax twice? Do you need to enforce
this? If so, you need a unique index on either (product name hash,
product tax code) or (product tax code, product name hash).
A product can contain one or more taxes hence this table is a relationship table that will
1) allow me to search all taxes for a single product or 2) all products that are tied to a specific tax
What is the relative frequency of these types of queries?
You will still be able to do both, but if you only need one
type a few times during annual tax preparation, it may not be
worth having an index for only that.
and I will use the unique numeric id if I want to delete one or more of the taxes tied to a single product.
My question: Should I have keys/indexes for each of the columns? Is it one of those questions that is best answered with six of one and half a dozen of the other? I believe in this case because the table is so small and likely only to contain a couple of thousand records at maximum, it would be unhealthy to have indexes as maintaining them would create a bit of an overhead. What though, if the table were to contain a larger amount of records (say, in the millions) but retain the same number of columns - what would be the best advice in this case?
Indexes take time to maintain WHEN YOU MAKE CHANGES (or when you
add or delete them). How often will you be changing the table,
compared to how often you make queries? Is disk space a big issue?
You might want to try queries with and without the indexes (You can
add and delete indexes with ALTER TABLE) and see if it makes enough
difference to matter. Certainly for a million records it would
save a lot in disk I/O.
If you aren't going to make a lot of changes to the table, go for the
indexes. If the speed of the changes is not a big deal, but the speed
of the lookups is (someone's waiting on the phone for a quote),
go for the indexes. If changes are about 10 times as frequent as lookups,
you may want only the index on the unique record id.
Gordon L. Burditt
Gordon Burditt wrote: Basically - I have three columns in my table... product name hash, product tax code and a unique numeric record id.
If you want the database to enforce uniqueness on the record id (e.g. it's an auto_increment), you need a unique index on that column.
Is (product name hash, product tax code) unique? Although a product can have more than one tax and a tax can have more than one product, can the SAME product have the SAME tax twice? Do you need to enforce this? If so, you need a unique index on either (product name hash, product tax code) or (product tax code, product name hash).
A product can contain one or more taxes hence this table is a relationship table that will
1) allow me to search all taxes for a single product or 2) all products that are tied to a specific tax
What is the relative frequency of these types of queries? You will still be able to do both, but if you only need one type a few times during annual tax preparation, it may not be worth having an index for only that.
and I will use the unique numeric id if I want to delete one or more of the taxes tied to a single product.
My question: Should I have keys/indexes for each of the columns? Is it one of those questions that is best answered with six of one and half a dozen of the other? I believe in this case because the table is so small and likely only to contain a couple of thousand records at maximum, it would be unhealthy to have indexes as maintaining them would create a bit of an overhead. What though, if the table were to contain a larger amount of records (say, in the millions) but retain the same number of columns - what would be the best advice in this case?
Indexes take time to maintain WHEN YOU MAKE CHANGES (or when you add or delete them). How often will you be changing the table, compared to how often you make queries? Is disk space a big issue? You might want to try queries with and without the indexes (You can add and delete indexes with ALTER TABLE) and see if it makes enough difference to matter. Certainly for a million records it would save a lot in disk I/O.
If you aren't going to make a lot of changes to the table, go for the indexes. If the speed of the changes is not a big deal, but the speed of the lookups is (someone's waiting on the phone for a quote), go for the indexes. If changes are about 10 times as frequent as lookups, you may want only the index on the unique record id.
Gordon L. Burditt
Thanks for those comments - it gave food for thought and I think I will
use the indexes since there will be fewer changes and more reads using
one column to lookup the other.
Thanks!
Randell D. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Randell D. |
last post by:
Can anyone tell me what the difference is between keys and indexes?
Much appreciated,
randelld
|
by: Randell D. |
last post by:
Folks,
I have a table that has five columns in it - It collates references to
records in five other tables. I understand that an index/key can help
improve performance when searching - however...
|
by: Aleem |
last post by:
I need help in writing a stored procedure on SQL Server 2000.
Basically the stored procedure's primary task is to generate invoice
records and insert the records in a invoice table. In order to...
|
by: Woody Rao |
last post by:
I'm trying to drop all indexes and primary keys so that i can rebuild them
(from a script created from same database on another server).
when i go to the 'generate sql scripts', it has the...
|
by: Vinodh Kumar P |
last post by:
I understand the number of foreign keys allowed is restricted by the DBMS I
use.
In a general relational schema design perspective how many foreign keys a
table shall have?
If I have large number...
|
by: Brendan Jurd |
last post by:
Hi all,
I read on the manual page for Inheritance that:
"A limitation of the inheritance feature is that indexes (including
unique constraints) and foreign key constraints only apply to single...
|
by: LurfysMa |
last post by:
Most of the reference books recommend autonum primary keys, but the
Access help says that any unique keys will work.
What are the tradeoffs?
I have several tables that have unique fields. Can...
|
by: lfhenry |
last post by:
Hi All,
I am about to make some changes to a process we have. The new process
will have a new table who's job it is to store temporarily data such
as customer, clerkno,productno, storeno , amount,...
|
by: Okonita via DBMonster.com |
last post by:
Hi all,
I am comming along with all this Linus/DB2/scripting business...I am no
longer scared of it!! (LOL). But,
I need to create a .ksh script that does a REORGCHK and output only tables...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |