Access Database is an extremely powerful tool for storing, retrieving and comparing data. However, designing a perfect database in MS Access is essential to build scalable, high performance application.
While creating an Access database, regardless of its ultimate purposes. Always try to follow the guidelines shortlisted for MS Access database best practices. As, this will ensures how much your Access database is useful and easy to handle.
These Access database practices will also help in easy avoiding of common mistakes occurred in Access database.
The main objective behind this tutorial is just to help beginner and database professionals with best Access database practices and techniques. So, that anyone can easily tackle any kind of rendered Access database issues and errors on their own.
Highlights Of Access Database Best Practices Complete Guide
- Access Database Best Practices For Effective Table Performance
- Access Database Best Practices To Build Effective Relationship Tables
- Access Database Best Practices To Build Effective Linked Databases & Tables
- Access Database Best Practices to Deploy Access Database to Multiple Users
- Standard Access Database Security Best Practices
- Microsoft Access Startup Tips
- Microsoft Access Query Optimization
- Microsoft Access Form Optimizations
- Microsoft Access Report Optimizations
- Microsoft Access Module/VBA Performance Tips
- Access Database Best Practices To Avoid Corruption Issue
Access Database Best Practices For Effective Table Performance
Every Table Should Have a Primary Key
In all table of your Access database don’t forget to put a primary key. As, this will help your database in faster searching of any specific records. Also, you can’t make secondary indexes on your Access table’s fields until and unless that table contains a Primary Key.
Primary Key Should be One Field and Numeric
Assigning primary key in the table means that the index is stable even when modifications done in data. Or else the change done in primary key will show ripple effect on each of the secondary indexes. Also, on any other table bound by referential integrity.
Primary key must be the one field and ideally numeric. This helps in adding uniqueness of each records that can be accomplished correctly with single number.
The best way is to make use of the AutoNumber field if you are an Access database user. But if you are an SQL server user then make use of the Identity column.
Tables Should Participate in Relationships
Related table having one-to-one or one-to-many relationship. Must implement referential integrity with cascading delete/update for ensuring that records were left single.
Using the cascading delete option in Access, you can easily remove the parent record along with the child records present in the corresponding table. Access database jet engine supervise this task so you don’t need to write any code for it. So, it’s the smart option to use for maintaining data integrity.
With the established relationship, for the foreign key a hidden index is get created. Automatically links will be drawn for you while putting two tables on your query designer.
Eliminate Unnecessary Sub-datasheets
Due to default setting, Access builds a sub-datasheet view between the related tables. If you need such sub-datasheets then keep it. Otherwise remove it, as this will hamper your Access database performance. For this you just need to set the Subdatasheet Name Property to NONE.
Choose the Optimal Data Types
Select the appropriate data type for your fields. As, choosing the optimal data type will reduce both disk space captured to store data. And time taken to manipulate/retrieve/write data.
Add Secondary Indexes As Necessary
If you have a table having huge amount of data then search on field, make a secondary index on field or use it in a join. Secondary indexes help to enhance performance on the order of magnitude.
Only put indexes in field were required. It’s important to remove indexed field which not required anymore. Each index adds extra time to the normal time duration taken by database engine to update/delete/append records.
Don’t Index Fields with Lots of Identical Data
No need to apply indexes for the fields which contains lots of similar data. If the number field contains only two or three value then indexing is a smart idea.
To count the numbers of unique entries in any index make use of the MS Access DistinctCount property.
Access Database Best Practices To Build Effective Relationship Tables
One very important key skill towards the proper working of the access database is how perfectly you build relationships in it. As, Access database relationships not only make your database more comprehensive but also makes it easier to manage.
So, here are some key tips to follow for making perfect Access database relationships.
Use Tables from the Same database
MS Access helps in making relationships between different tables using one single database only. Don’t try to make relationships between tables which are present on completely different databases. For making relationships between such different database’s tables. You need to import either tables in either of your Access databases.
Focus on creating relationships between Tables only
Don’t get into the complex portion of relating table to a query for any other objects. After having clear mindset for building relationships between tables and its steps. You can also approach for relating other objects too.
Explicitly state Relationships
Specify how tables are related, if because if it contains no clarity then it fails to work. So, having common field in different tables is not been enough. Try to explicitly create relationships between tables so that it will clearly apparent that, they are related with each other.
Access Database Best Practices To Build Effective Linked Databases & Tables
Keep an Open Handle to Every Linked Database
To raises the performance of opening reports, tables and forms which are related with linked tables.
Try opening database variables in the VB (VISUAL BASIC) code through OpenDatabase method. Leave it open utill and unless your application is executing. This helps to keep your database open and also allows faster accessing to linked tables.
Minimize Record Navigation
Reduce record navigation, whenever it is possible with linked tables mainly with the bulky SQL server tables. Make use of page up & down movements, only when it’s necessary.
Use DataEntry Mode
If you need to add records, make use of DataEntry command from records menu. Well the data access method is quiet efficient for addition of records. As you can’t read from database because of its already existing records.
Create a Data Entry Form
In order to add any new records to your linked table, try to create an “Add Records” form. After then set the DataEntry property of Form to Yes option. This will prevent Access database to recover records already existing in the linked tables when needs to enter any new records.
Limit the Data Returned by Queries
Use limited number of records and fields comes after using the queries and filters. As, this may reduces the data amount requires to be read from MS Access linked table. This will further enhance your Access database performance.
Don’t Use Domain Aggregate Functions
If your written query depends on either one or more than one linked Access tables. Then in that case avoid using Domain Aggregate Functions within the query criteria. Because when this domain aggregate functions like DLookup, is used. It will pick out all the records present in function of the data source for execution of query.
Release Locks ASAP
For improving multi-user concurrency, consider that some other users also try to edit linked table’s data which you are currently been using. Keep your records locked when it’s necessary.
Access Database Best Practices to Deploy Access Database to Multiple Users
One very frequent question raised by several Access users is how to make multi-user database secure, fast and upgradable.
Deploying access database within your organization or on your customers end. So, it’s important to think how to avoid performance degradation, reliability issues, significant security or data loss issues.
The below section discusses about the Access Database Best Practices to deploy Access Database to multiple users.
Splitting Up Your Database:
This step is important for making upgrade to your end users easily. Split Access database simply means you have one file which contain your complete table data. This section is called as back end.
And the other part is called as front end which contains no data, only database objects queries, forms, and reports.
Standard Access Database Security Best Practices
Access Database security best practices needs proper handling of sensitive data and latest knowledge over cyber threats. Your professional Access database must contain such information which are usually targeted by cyber-crime to steal financial details, identities and credential.
Here are some best database security practices which works wonder in keeping your company database completely safe & secure.
Keep Security Controls Of Database Server On Maximum:
Make sure you are running most updated Access database version for removing out the vulnerabilities. Turn on the security controls and protocols of your Access database and website server. Until you get any specific reason to turn it off.
Along with that, make sure to delete or disable any services or features that are no more of your use. At the end don’t forget to change all default passwords to obstruct unauthorized users from logging in.
Separate Servers And Web Servers
In Access database security best practice, second most important step you need to perform is keeping separate servers and web servers.
You need to separate your database server from your website server for improving Access database security. Doing such things will raise the cyber security of your database server. So, even if any hacker cracks down the password of your web server admin account. Then also they get fails to access your database.
It’s among the best Access database practice for keeping unnecessary programs separately from server which they don’t need any more. When these servers communicating with each other’s. It’s important to ensure whether the permissions are set to lowest level of privileges required for them to operate them successfully. This actually helps in limiting the scope of attackers implementing damage technique.
Encrypt All Files And Backups
It’s doesn’t matter how much tight your Access database security is. There is also a risk that hackers can infiltrate your system. But one thing that you all must not be aware with is that. Little negligence in encrypting database files and backup also open doors for database vulnerability.
So, by encrypting your database you are making it unreadable for both hackers and any third-party users. As, for this they always need to enter encryption key which adds final step toward defense against annoying intrusion. So, to make your crucial data unreadable to unauthorized user encrypt all your data files, backup and documents.
Put A Database Firewall And Web Application Firewall In Place
Firewalls helps to improve database security by reducing the threats entrance. Once it set up properly, it will only allow traffic from specific applications and web servers which requires data accessing and also works preventing your data from setting up outbound connections.
Along with this, applying web application firewalls gives better protection to your web servers and also increases database security. Web application firewall actually keeps your data behind the firewall and also away from prying eyes of cyber criminals.
Regularly update patches
If you are using any kind of third-party apps, widgets, plugins in your database, then cyber-criminal will may to break your database security. Mainly if you haven’t updated the patches regularly. Even though your internal defense is strong, but still the additions of these third-party apps can create weaknesses. So, make sure to update all your app, widgets, plugins etc. updated for keeping intruders outside the reach of your database accessing.
Microsoft Access Startup Tips
Remove Code From Your Startup Form
If you are using a startup form in place of Autoexec macro. Then in that case put the visual basic code in form module which is required for that form. So as to load your startup form Access will automatically load form’s module which is faster as compared to standard module. This will ultimately decrease your database loading time.
Minimize Startup Form Code
In your startup form, try to make use of lesser coding. you may need to use some operations like opening of the data Access objects in code. This technique will help your application to get load faster.
Don’t Use ActiveX Controls on Startup Form
Restrict yourself to use ActiveX controls on your Startup Form. As ActiveX Controls consume more loading time as compared to other controls. And thus, your application loading time will get raise.
Automate the Deployment of the Latest Version of Your Database
Manage and simplify the automatic deployment of the access database on each PC. While updating your database. After updating your application, you may want to distribute it easily and quickly. If you are distributing your database in multi-user environment then make sure that each of user is using the updated version of Access database.
Microsoft Access Query Optimization
Compact Often to Update Statistics
You need to compact the database often. As doing this, will help reorganize the records in their adjacent spaces and further this makes the retrieval process faster.
Apart from this, compacting database also works to updates statistics which greatly affect the faster execution of query. You can recompile the query, by opening, saving and running it in design view.
Take Advantage of Rushmore Query Optimization
Microsoft Jet database engine make use of Rushmore query optimization whenever it is possible.
Rushmore is best to apply for queries which run on native access data and on those are linked to FoxPro and dBASE tables. This optimization technique doesn’t support linked data type. To check Rushmore optimizations, make indexes on the entire field which are used to restricts the output of query.
But if you don’t have such queries used in query’s restriction clause which contains indexes on fields. then in that case Rushmore query optimization is not applicable.
Link on Primary Key Indexes Whenever Possible
For faster execution of queries, you need to put indexes on all fields present in query which sort, restrict or join the data. Try to make links on the primary fields as compared to other fields.
It’s quite difficult to put indexes on the tables having large number of records. So, you may won’t get any much difference on small tables. Nor, you need to add any secondary indexes on the fields which are the referential integrity’s part.
Try experimenting with the Sub Queries Instead Of Joins
Having query in which you have used join but it’s not working correctly. In that case you can replace the join with sub query. As in some case it is observed that sub query increases the execution time of query optimization.
Microsoft Access Form Optimization
Keep Forms Lightweight With Hyperlinks
It gets quite easy to open Access objects if hyperlink is used in label controls. So, avoid using command button on your forms and look for the possibilities of using label control having hyperlink properties. this particular Access database form designing practice removes off the necessity of command button and its related events codes.
Split Forms Into Multiple Pages
Always split your forms into multiple pages as this helps reducing the form loading time.
Suppose, your form contains 10 combo box control which take s along time to get load. But by making use of PageBreak control you can split the form into multiple pages. After then 5 of your combo box control is placed on first form page and rest of the control buttons are placed in another sub-form pages.
Doing this will automatically reduce the loading time for each of your form page. As none of your form or sub-form pages having heavy data items.
Avoid Overlapping Controls
You need to prevent overlapping of control for the right Microsoft Access form optimization. Because overlapping of controls on form will draw more accessing time in comparison to non-overlapping controls.
MS Access Report Optimizations
Avoid Unnecessary Property Assignments
Avoid using unnecessary property assignments because it harshly affects your Access database report performance. Make a complete check over your form’s startup code to make sure that you are not setting any unnecessary control or form properties in your report.
Minimize Bitmap Usage
As compared to other controls, make use of the bitmap or some other graphic objects. As, these will works better in improving the Microsoft Access report performance.
Use the Image Control
Apart from this, instead of using unbound object frames start using image control to display bitmaps. As it has been observed that image control is the best control type for graphics images.
Microsoft Access Module/VBA Performance Tips
Declare String Data Intelligently
Strings created by the user is quite different as the one created by visual basic. String variables make use only the PC’s Stack whereas Visual Basic allocates stack and heap memory both.so here are the following ways to write code which will automatically minimizes down your PC’s stack memory usage.
- Fixed length string which are less than or equal to 64 characters, captures 2 bytes for each of its characters in string. And they don’t make use of the heap memory.
- Local fixed length strings having more than 64 characters captures 4 bytes of stack memory in heap memory. This space is captured by pointer to variable value. Whereas string’s each character captures 2 bytes of heap memory.
- Local variable length string occupies 4 bytes of stack memory. As per the length of the string variable amount of heap memory is used.
- So, if your code is having huge number of fixed-length strings. Then it to reduce it minimize the stack usage by making modifications in the the string to local variable length strings. Or make use of the static fixed-length strings.
Minimize OLE References
Whenever you reference any visual basic method, property or method, one or more calls of the OLE dispatch interface are also get initialized. Each of these calls takes time to execute. By limiting the number of such calls you can easily improve your Access Module/Access VBA Performance. As, it makes your coding to execute faster. In order to reduce the OLE references, try the following steps:
- Make use of the object variables in place of directly referring the objects.
- To minimize object references make use of With statement.
- shift references to the properties and methods present outside the loops.
- While referring to collection’s member, make use of the object’s index number. Because, referring to the collection’s member with an expression number or name consume extra time to execute.
Access Database Best Practices To Avoid Corruption Issue
Compact And Repair Database
Note: Before you start with process, it is suggested that you must keep the backup of your database files that you are going to compact and repair.
The following steps is applicable to compact and repair Access Database 2016/2013/2010.
Step 1: Open Access, but do not open database. Click on File.
Step 2: Point the cursor to Info and then click on Compact and Repair Database.
Step 3: Now in the Database to Compact From dialog box, browse and select the database that you want to compact and repair.
Import Corrupt Database into new MS Access Database
Generally it is seen that corruption of Access database can easily been resolved with the method of importation. Basically in this method corrupted database is imported to new access database. Here is the following step to import corrupt Access Database.
- First of all open your MS Access application and create new database file. Hit the create option to make a new file in right side section of the panel.
- In the new database file windows, hit to the External Tab option from the above ribbon.
- Tap to the Access option as by pressing to this option you can easily import of your Access database.
- This will open up a new window named with Get External Data – Access Database.
- So, tap to the browse button and make selection of your corrupt/damaged Access database file to import.
- Browse and choose access database file in File Open dialog box. Tap to the Open option to confirm your selection.
- After then, hit to the OK for further continuation of the process.
- Make selection for the objects in Import Objects dialog box and again press the OK option.
- Complete of your selected objects get imported successfully.
- Press save import steps box and hit to the close.
After completing all these, the data from corrupted database should now be in the files that you have just created.
Go With The Recommended Option:
There are situation occurs where none of the inbuilt compact and repair tool nor any manual method works to resolve Access Database Corruption issue. In that case you need to approach for Access Database Repair And Recovery Tool as it is most appropriate tool for fixing up any corruption issue occurred in your Access Database.
With this highly prominent tool you can resolve any kind of MS Access error blots, partially corrupted Access database files (.accdb/,mdb). And restore the database to complete new fresh file without any difficulty.
I have tried my level best to infilled you all with enough information on basic Access development best practices. And also shared best troubleshooting tips to avoid Access database corruption issue of which any developer or user should needs to aware of. Implement all the aforementioned Access Database Practices for problem free accessing of your MS Access database.