views:

175

answers:

5

I work in a call centre that uses single table Access database for its calling, which I moved to a SQL server based system. There's a data list table (not normalized) and a calls table. This has about one update per second currently. All call outcomes along with date, time, and agent id are stored in the calls table. Agents have a predefined set of records that they will call each day (this comprises records from various data lists sorted to give an even spread throughout their set). Note a data list record is called once per day.

In order to ensure speed, live updates to this system are stored in a duplicate of the calls table fields in the data list table. These are then copied to the calls table in a batch process at the end of the day.

The reason for this is not obviously the speed at which a new record could be added to the calls table live, but when the user app is closed/opened and loads the user's data set again I need to check which records have not been called today - I would need to run a stored proc on the server that picked the last most call from the calls table and check if its calldate didn't match today's date. I believe a more expensive query than checking if a field in the data list table is NULL.

With this setup I only run the expensive query at the end of each day.

There are many pitfalls in this design, the main limitation is my inexperience. This is my first SQL server system. It's pretty critical, and I had to ensure it would work and I could easily dump data back to access db during a live failure. It has worked for 11 months now (and no live failure, less downtime than the old system).

I have created pretty well normalized databases for other things (with far fewer users), but I'm hesitant to implement this for the calling database.

Specifically, I would like to know your thoughts on whether the duplication of the calls fields in the data list table is necessary in my current setup or whether I should be able to use the calls table. Please try and answer this from my perspective. I know you DBAs may be cringing!

Other Background There's a compilation database which is a mirror of the live db structure really with 1.5m data list records, 3m call records, live db data list table doesn't have all the fields of the comp db, it has 0.25m data list records and about 0.5m calls records.

A: 

I would ask you to be a little more clear about the specific dilemma you face. If your system has worked so well for 11 months, what makes you think it needs any change?

Ian
The nagging voice in my head that says i need to make it more "professional". I asked this question while i was developing the database on other forums, the best answer i got was a guy who made a similar system and said he used a 3rd table 'final call' that only held the last call, and used an insert trigger to copy each new record into the calls table. But i didnt get the benefit of this over my design. I just found stack overflow and though id get another opinion. Maybe i should set my vanity aside and stick with what i have, structural changes now would no doubt rock the boat.
g_g
A: 

I think whether to normalize it depends on how much you can do, and what may be needed.

For example, as Ian mentioned, it has been working for so long, is there some features they want to add that will impact the database schema?

If not, then just leave it as it is, but, if you need to add new features that change the database, you may want to see about normalizing it at that point.

You wouldn't need to call a stored procedure, you should be able to use a select statement to get the max(id) by the user id, or the max(id) in the table, depending on what you need to do.

Before deciding to normalize, or to make any major architectural changes, first look at why you are doing it. If you are doing it just because you think it needs to be done, then stop, and see if there is anything else you can do, perhaps add unit tests, so you can get some times for how long operations take. Numbers are good before making major changes, to see if there is any real benefit.

James Black
+2  A: 

Redesigning an already working Database may become the major flaw here. Rather try to optimize what you have got running currently instead if starting from scratch. Think of indices, referential integrity, key assigning methods, proper usage of joins and the like.

In fact, have a look here:

http://stackoverflow.com/questions/621884/database-development-mistakes-made-by-appdevelopers

This outlines some very useful pointers.

Kyle Rozendo
+1 for the great link.
Tom Bushell
+2  A: 

The thing the "Normalisation Nazis" out there forget is that database design typically has two stages, the "Logical Design" and the "Physical Design". The logical design is for normalisation, and the physical design is for "now lets get the thing working", considering among other things the benefits of normalisation vs. the benefits of breaking nomalisation.

The classic example is an Order table and an Order-Detail table and the Order header table has "total price" where that value was derived from the Order-Detail and related tables. Having total price on Order in this case still make sense, but it breaks normalisation.

A normalised database is meant to give your database high maintainability and flexibility. But optimising for performance is one of the considerations that physical design considers. Look at reporting databases for example. And don't get me started about storing time-series data.

Ask yourself, has my maintainability or flexibility been significantly hindered by this decision? Does it cause me lots of code changes or data redesign when I change something? If not, and you're happy that your design is working as required, then I wouldn't worry.

Swanny
Not exactly - normalization is for data consistency. Flexibility is only there if the designer had foresight, but even then that's only based on the business requirements at the time.
OMG Ponies
A: 

I'm not sure you are aware of the fact that "Database design fundamentals" might relate to "logical database design fundamentals" as well as "physical database design fundamentals", nor whether you are aware of the difference.

Logical database design fundamentals should not (and actually cannot) be "sacrificed" for speed precisely because speed is only determined by physical design choices, the prime desision factor in which is precisely speed and performance.

Erwin Smout