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 1681
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 relationshi p 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 I also believe too many
keys can hamper performance since table updates also mean updateing the
indexes.
Thus - Since all five columns in my table can be used individually for
specific searches, would I be better off not having keys - Since the
|
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
generate the invoice records, I have an initial table which are
basically Day Records. The task that I would like to complete is to
select all records from that initial table and I guess put them into a
temp table. Now that i have my temp table, I...
|
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 ability to drop or
generate all
tables. it also has the ability to generate all keys only. but i cant find
a way
to drop all of these keys...
any ideas?
|
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 of foreign keys what anamolies it will lead to?
Is this crucial to identify all the foriegn key relationships for a table?
Vinodh
| |
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
tables, not to their inheritance children. Thus, in the above example,
specifying that another table's column REFERENCES cities(name) would
allow the other table to contain city names but not capital names. This
deficiency will probably be fixed...
|
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 I use them as
primary keys or should I define an autonum primary key?
One table has information about the 50 states in the US. The table
looks like this:
|
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, time.
On a new request from a front-end i will select against the primary
keys to ensure no other request for the same data has been made. This
is then sent to a backend system asynchronously if there is no match.
I will otherwise send a...
|
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
recommended for reorg.
My goal is to reorgchk and run reorgs based on entries in this reorg file as
shown in the example below.
I have tried my hand at the following failing script and hope that gurus here
can throw me a lifeline of examples on how to...
|
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,...
|
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...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |