Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question: Putting Entities in one or two tables...

Status
Not open for further replies.

omniaccess

Technical User
Feb 2, 2005
16
US
I have a relatively complex project of clients, suppliers, employees, manufacturers, contractors, etc.

I have fully developed the client area of my program by having a table with only about 15 or 20 fields for each client. These fields are enough info to identify who they are, such as client type, last name, first name, other name, business name, when created, created by, changed date, and changed by. For all the other information about each client there are multiple tables in one-to-many relationships so that each client can have multiple addresses, contact members, contact info, dates, schedules, etc. It has been working quite well, even though I have had to watch out so I do not connect too much information together at the same time and slow down the system (in other words, too many tabbed pages with connected subforms all active at the same time).

I am now at the point of adding Suppliers, Manufacturers, Employees, and contractors to the equation. I refer to all of these people as resource entities for the business.

Here is my question: Should I put all of the resource people in their own table and keep them separate from the Client table, or should I use the existing structure to put all entities in the same table with my clients. I am not sure which arrangement for tables would make the most sense for building for the future. This layout could be used for much larger systems in the future.

Several other factors: (1) in my scheduling section of the program, I have made it so you can schedule more than clients, such as office tasks, communication, etc. In the scheduling, I was thinking it would be nice to be able to select a supplier (in the "who" field of the schedule item) to order parts. Or schedule an employee if scheduling an employee review. Or selecting a manufacturer if an appointment is set to meet with that company rather than working with clients. This would be flexible, but would make sense if the resource people were all in the same table as the clients.
(2) It would aid in global searching for anyone because all entities would all be in the same table.
(3) Management would be easier because they would all be in one table and whatever resources they have would simply be attached through other tables and subforms specific to their entity type (One form has attached subforms that relate to clients, another form has subforms and tables related to manufacturers, etc.).
(4) They would all have global reference ID separate from each other because none would get assigned the same ID if they are all in the same table.

The immediate drawback I can think of is that the entity table will get larger than if they are separate. At this point, the client list has nearly 10,000 clients in it, and I can imagine the manufacturers and suppliers also getting up to 10,000 entries in it.

Another drawback is that anyone who does power searches on the data would always have to remember to specify which entity type they are, whether a client, manufacturer, Supplier, etc.

One other drawback would be in selecting an entity from a combo box. It would probably work to put "sort by" or "show Type" selections near the combo box to sort or filter the combo box to quickly show them only the entity type they want.

Currently, the program will be running on one or just a few computers at a time. It is possible it will get scaled up to a SQL server backend for larger installments.

I have seen many programmers layout a separate table for each entity type (Client, Manufacturer, Supplier, Employee, Contractor, etc) but I would rather handle their differences though related tables and subforms applicable for each entity type.

I would appreciate anyone's input who have considered this issue or who have dealt with tables with these type of numbers and have seen positives and negatives to their layout. Thank you

 
I would tend to separate these entities as they are separate in the real world (maybe not employee/contractor).

I don't think 20,000 rows is anything to worry about.

Another drawback is that anyone who does power searches on the data would always have to remember to specify which entity type they are, whether a client, manufacturer, Supplier, etc.
You are talking about how you store data. Presenting data is done by views (principally queries in Access). There is nothing to stop you having two views (eg Clients and Suppliers) that actually refer to the same table. You put the WHERE RTYPE='Client' in the query so the user doesn't have to worry about it.

 
omniaccess

Nicely done!

There is no easy answer to your delema -- no surprize I am sure or you would not be here.

My experience, for what it is worth, is to use one contact table. Why? Well a supplier can become a customer or contraactor. Also, you may find you have to duplicate the logic and code elsewhere.

An obvious approach to using one table to have a field ContractType added to the design. Fairly simple and easy to work with. Your concern about have the end user to remember to specifiy one type or another can be addressed by tweaking your combo boxes / cascading combo boxes. Find Manufacturer -> Next combo box displays list of manufactures.

I have not done this, but if a contact can be more than one type, you can have tables that reference contacts belonging to the group...

tblManufacture
ContactID - fk to Contact table

tblContractor
ContactID - fk to Contact table

...OR use M:M junction table

ContactType - "manuf", "contr" ...
ContactID

You would have to play to figure out which is the best approach.

Richard

 
Thanks for your input! I have always desired to stay the most "Flexible" in design, and all-in-one table seems to fit that.

In the current version of the program, they will only be able to allocate one entity type to a entity, but in the next revision, I will add a one2many table so one entity can be more than one entity type. I don't like to include too many m2m relationships in my system unless the benefit of m2m cannot be ignored.

Again thanks. I think I have been pushed over the edge as to how I am going to do it.

Thomas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top