Database Architecture - Handling Data for Different Customer Needs
I'm very anal about trying to maintain development standards when designing applications. This puts me in a difficult situation because every company I've worked for let's standards slide (or doesn't care) and especially in regards to data. This compromise is usually attributed to the lack of time that's available but other times due to the complexity of the data.
So, I am again faced with a project that may compromise the relational database model and I would like input from other people who've been in my situation. The situation is that my company currently has several stand alone applications geared towards different customers. Each customer has similar yet different data requirements but we would like to merge all of our separate applications into one and thus house all of this data under one database. I am perfectly o.k. with this concept but what is the best approach for designing the central database?
For example, we have a table for entering time sheets. Company A's table may look like:
Customer Number, Employee Name, Hours, Equipment Used, Description, Work Expense, Back Charge, Additional Charge.
However, Company B's table may look like:
Customer Number, Employee Name, Hours, Equipment Used, Description, Additional Charge.
My boss would like to make an aggregate table that looks like:
Customer Number, Employee Name, Hours, Equipment Used, Description, Desc1, Desc2, Desc3, Charge1, Charge2, Charge3.
Obviously, doing it his way would mean that all of the last columns for Company A would mean something entirely different for company B within the same table(entity). I've ran into this situation before and it became quite confusing when fixing data issues. Also, this situation requires a lot of upfront data checking by the UI and prohibits using solid abstract layering standards. On the other hand, this lowers the amount of tables needed and makes updating a cinch (possibly).
Is there a better way to design this?
I worked with one company that did something similar where they had attribute 1 to attributeX columns with a type field. Depending on the type, attribute1 meant something different in record 1 than 2. This was a mess because all of these fields were integers and required complex joins in order to bring in the descriptions. Then, if we needed to add another bit of info for company A, we had to add another attributeX field and re-program all of the UI's to handle this change.
Thank You for your input.
Similar issue - how to make it efficient & flexible
Hi illumina,
I am in a similar situation, yet a little more tricky maybe. I am working for several organizations, who have several databases with people. From their internal workers, to members, newsletter subscribers, partners,... all in all, quite a mess since everyone is using different tools, and no one is really happy about they have.
So I went on a quest of finding an address book sort of web app, that would be simple to use, and extremely flexible/scalable to reach all the needs. Mission Impossible, I didn't find anything. We've decided to launch our own Open Source project, and I am currently designing the web app.
But I am running in the same problem as you are, the whole point of it is that each administrator can build his own data structure from the user interface, without any coding. But my plan is to go further, allowing the use of plugins to define data types, and means of exporting the data. This would allow you to build all kinds of systems fitting the needs.
If you want to know more about it, you can read about it on our sourceforge project page, project named "adres"
But here is the design challenge !
--------------------------------------
To keep it flexible, I would like to let the plugin be responsible for his set of data. The plugin becomes therefore a black box. It can process a search, return a string to display it's value in a grid,... plugins are PHP classes that will extend an Interface called Field.
Now, it's much better to let MySQL do the filter and the sorting rather than trying to do it in PHP since MySQL is optimized for that. But plugins are PHP black boxes. So if I wanted to display all the data, I have to go through each contact, and for each field call the getString function.... That's plenty of SQL requests.
Better, I can ask a plugin to send me all the values for a certain Filter. In that way I can extract the datas column by column. But it makes sorting a little difficult... But so far, it seemed to me that this was probably the best solution. Giving a lot of freedom to the plugin developers.
But then I had an other idea, what about having the plugins sending back the information required to build one SQL request. They would send me the name of the table, the connecting field name, the parts that goes in the SELECT",... That would make searching and sorting a lot easier, and could be processed in one request. But is that really a good idea ?!? It sounds a little pulled by the hair in one way, but maybe it's the best way.
It feels like I am really mixing the logic and data layer, which is normal in one way since I want a dynamic data structure. But I just wonder if I'm not missing a point there.
Any suggestion ???????
If you wanna dig more into that question, check out the document called documentation.pdf on Sourceforge. I am discussing some of these options in a deeper way. But please forgive me for the quality of the writing, it's a working document, not a publication ;-)
2 Attachment(s)
Common Driver for Processes
Hi, Jobsezage,
This is getting more interesting by the minute ! All interactions in business are driven by the relationship between the various entities and what I find intriguing is that we both seem to be trying to attack this basic business premise from different perspectives. You are endeavouring to leave as much to the user as possible and simply provide processes (plug-ins) to manage whatever he/she decides to specify. This may be the way to go in the web/cloud world. I, on the other hand have taken the view that inter-entity relationships are real, but that the nature and extent of these relationships is defined by the parties. Hence, in my server/client system, the de-facto real world relationships each carry with them one or more codes (which I call roles and can be user-defined), which are used to define the different manners of engagement. The user can write the code (or access a library) using the entity keys and the role key as parameters. For instance, one module may process orders, and another payments (which may cross-reference orders through their repsective role keys.)
Actually, all my stuff originated in some ideas for bringing sophisticated decision-support capability to small business and the entity model was my means of connecting what may be fairly remote areas in the overall business model.
For your interest, I attach an entity/relationship diagram and notes which may (or may not) be useful to you.
Back to the original question
You know, some of us have been having such an interesting conversation about a few ideas of interest that we seem to have forgotten about the problem posed by our colleague illumna ! Now, the premise seems to be that he has a number of versions all describing different versions of the same entity and he would like to have an overarching structure that would enable him to have a common extraction/processing mechanism that would handle all variants.
My line of thought that I have expressed in my contributions is to have a core entity table which essentially contains identification and relationship data (common to all versions) linked one on one to different information tables which contain the variable client data. The entity table would identify the variant and the type ID, if you will, would be a switch to invoke dedicated processing for each variant. This approach derives from my work on decision support systems, which need to reach the extremes of very large systems.
A simpler alternative (depending upon other constraints not yet offered by illumna) would be to create a database table where some fields would be common to several of the contributing client tables and others would be specific to some clients who were the only ones collecting the data in question. Any processing functions would know how to process all fields.
The requirements would be queries which will draw on the contributing databases and transfer the data to the appropriate fields in the new database. if you wanted to retain all of the individual reports in the different databases, you would need complementary queries to extract the data and present it as an alias (or put it directly into a table which would be referred to by the reports.
As I understand it, jobzesage favours providing functions (called plugins here) which will read the structure of each client table presented and then, through some switching mechanism, either process the data in a way consistent with the structure which has been read, or refer to some code provided by the user.
The solution selected, I would suggest, depends on where you would want to go next, illumna.
I hope that our earlier contributions or this summary are useful to you.