Solved

Info about Hash method

Posted on 1997-09-11
6
177 Views
Last Modified: 2010-08-05
I need use VB 4 to managment a big database (maybe a 800 hundred to one million records), and someone said me that is better use the hash method than a access database.
What is the hash method, where I can get info about it, and why and must select it before a access format.
0
Comment
Question by:cano091197
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 

Author Comment

by:cano091197
ID: 1434794
Edited text of question
0
 

Author Comment

by:cano091197
ID: 1434795
Adjusted points to 200
0
 

Author Comment

by:cano091197
ID: 1434796
Edited text of question
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:Sinclair
ID: 1434797
If you wish to make your own "database engine", you can use a hash table. A hash table uses some sort of a hash function to assign a number to every record in the database. Then, you can make a hash table which is an array whose indices correspond to the hash numbers, and whose elements contain pointers/file offsets/whatever which point to the records.
Example: suppose you have a database of strings, and your hash function assigns a number to every letter of the alphabet (A=1,B=2, etc.), taking the first character of every string and returning the number. So, if your database contains the following records:

File offset   Record contents
   1             Apple
   20            Book
   63            Doom
   48            Zargon

your hash table will look like this:
Array Index    Contents   (Implied record)
  [1]            1           Apple
  [2]           20           Book
  [3]         Nothing      
  [4]           63           Doom
  [5]         Nothing
  ...
 [26]           48           Zargon

Now, if the user wants to find "Zargon" in the database, all you have to do is run it through the hash function (which will give you 26), and go to the file offset specified in the 26th position of the array.
Problems arise when "collisions" occur, that is, your hash function returns the same number for two different records (in my example, this would occur if the database contained both "Book" and "Bread").
This is really all I know. A good, cheap hash method would be to compute a checksum of every record (XORing it in some way), but I have read that this is not very efficient... You will have to ask the real experts for more info.
0
 
LVL 9

Accepted Solution

by:
cymbolic earned 200 total points
ID: 1434798
Sinclair is correct.  Hashing algorithms are merely methods of quickly calculating record offsets by using some of the data in each record as input to any of a numbe of algoritms, but all of which are based on uniqueness in your data, and customizing the algorithm upon that uniqeness to get the minimum of collisions.  Pick up any basic computer science textbook to get a more complete description, with examples.

However, speed is traded off with space in thes implementations.  That is your saved space must be much larger than your actuall needed space to avoid colissions wen your hashing algoritm calculates the same record number for two differrent records.  also, you usually need some link pinter method to resolve duplicate record number calculations.

However, the picture is not that bad because your original advice is flawed.  Access will still work well for you, you just need to take care in how you define your keys and indexes.
He's right in that it is better not to assign sequential keys if/when doing mass inserts inot the database...but...how often do you do that?  The problem is that Access tries to allocate records contiguously on the same block or page based on the primary key for your table.  Since is locks by page, if you are updateing consecutive primary keys, you will lock many adjacent rows as well.  These potential limitations are really based upon you methods of adding, updating, and reading the records.  If you are selecting based upon criteria other than your primary key, these limitations won't be a problem.  SOOoo...it all depends!

Also, you can use a form of hashing algorithm in Access as well.
Just calculate primary keys (many experts suggest using large floating point number results because the possibility of duplicates is smaler with a larger number range) instead of assigning sequential numbers.  

This presupposes that you are using primary keys that are not also data items.  Hope this helps.
0
 

Author Comment

by:cano091197
ID: 1434799
I ask for source information and nobody wrote about it
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question