开发者

What kind of structure is that?

In the project where I work I saw this structure in database, and I ask to all of you, what a hell of modeling is this?

TableX
Columns开发者_如何学运维: isMonday, BeginingHourMonday, EndHourMonday, isTuesday, BeginingHourTuesday, EndHourTuesday and so on...

Is this no-sql? I did not asked to the personn who created becaus I'm ashamed :$

Bye.


this is totally de-normalized data. no-sql kind of. i just wonder why month is not included. it could increase the de-normalization-factor.


This is called a calendar table.

It is a very common and incredibly useful approach to dealing with and solving a lot of date and time related queries. It allows you to search, sort, group, or otherwise mine for data in interesting and clever ways.


@Brian Gideon is right. So is @iamgopal. And I am too, when I say "it depends on the nature of the data being modeled and stored in the database".

If it is a list of days with certain attributes/properties for each day, then yes, I would call it denormalized -- and 9 times out of 10 (or more) this will probably be the case. (I recall a database with 13 columns, one for each month in the year and one for total, and at the end of the year the user added 13 more columns for the next year. "Mr. Database", we called him.)

If this is a description of, say, work hours within a week, where each and every time the data is queried you always require the information for each day in the week, then the row would represent one "unit" of data (each column dependant upon the primary key of the table and all that), and it would be counter-productive to split the data into smaller pieces.

And, of course, it might be a combination of the two -- data that was initially normalized down to one row per day, and then intentionally denormalized for performance reasons. Perhaps 9 times out of 10 they do need a weeks' worth of information, and analysis showed massive performance gains by concatenating that data into one row?

As it is, without further information on use and rational I'm siding with @iamgopal, and upvoting him.


Looks like a structure of a timesheet for a given week.
If normalized, it might look like

columns: day, startHour, endHour
When this is converted to a pivot table in excel, you will have a timesheet kind of a structure, which is good for input screens/views (as against creating a view with normalized structure).


Looking to that table. I don't see any good reason to do that, even for a performance reason.

Lets see, if I change the isMonday, isTuesday, etc to ID_Day I still get the same speed and logic. And if I change the BeginingHourMonday to StartHour and the EndHourMonday to EndHour, I still get the same effect.

I still have the day of week and the start and end time and that is the basically idea I get from the table struture. Maybe there is something I'm not seeing.

Regards

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜