473,756 Members | 9,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Month Year Table

Hi,

We are using Month-year tables to keep the history of long transaction
of our application. For example:

We capture the details of a certain action in table
"TransDtls<Curr Month><CurrYear >" (this month: TransDtls072005 ).
This way tables keep growing. every month a new table gets created. We
have done it because we estimated that every month year table will
carry around 2 - 3 Lac records and most of the time the operations will
work on current month year table.

Avoiding this way and carrying on with single table instead of "Month
year" table might lead us system performance issues.

But now we are a bit confused on the way we are heading and also facing
the implementation issues like manipulating data from different
"month-year" tables. Could anyone please help us to make our vision
clear on this?

Looking for your valuable comments.
Thanks.

Jul 23 '05 #1
8 3622
Take a look at partitioned views in Books Online.

--
David Portas
SQL Server MVP
--

Jul 23 '05 #2
I would really like appreciate that you have got my problem clearly and
want to be thankful that you tried to point the would be solution of
this issue,
however I should say here that the rules applied on "Partitione d Views"
would trouble even more as there are situation and logic is developed
accordingly where the data grows unlimitedly in a single table, whereas
primary key column in partitioned tables require prefixed range set.

This is the first doubt about this solution in mind. Would revert back
with more.

Jul 23 '05 #3
Zero.NULL (ma******@gmail .com) writes:
I would really like appreciate that you have got my problem clearly and
want to be thankful that you tried to point the would be solution of
this issue,
however I should say here that the rules applied on "Partitione d Views"
would trouble even more as there are situation and logic is developed
accordingly where the data grows unlimitedly in a single table, whereas
primary key column in partitioned tables require prefixed range set.
Huh? Could you clarify what you mean?

Since you create YYYYMM tables every now and then, you would have to
recreate the view every you do this, but that's not a big deal.

In your original post you said:
We capture the details of a certain action in table
"TransDtls<Curr Month><CurrYear >" (this month: TransDtls072005 ).
This way tables keep growing. every month a new table gets created. We
have done it because we estimated that every month year table will
carry around 2 - 3 Lac records and most of the time the operations will
work on current month year table.


"Lac" is a unit that is unknown to me. Could you explain?

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #4
The name of this design flaw is attribute splitting. That means you
take waht should have been one table, find an attribute and use the
values of the attribute to make extra tables that shoudl not exist. If
you had split "Personnel" into "MalePerson nel" and "FemalePersonne l"
you would see the fallacy immediately.

What you have re-invented is the old IBM mag tape file system labels
that had a "yymmm" numbering. You even say "records" because you do
not know why a row is not a field and a column is nothing like a
record.
Avoiding this way and carrying on with single table instead of "Month year" table might lead us system performance issues. <<


Why don't you worry about data integrity and correct design first?
Hey, if nothing has to be right, I can make it run really fast -- the
answer is always 42!! Get the design then and only then, worry about
tuning.

Jul 23 '05 #5
Erland, I apologize to use a regional unit here. Lac is equal to 0.1
Million

Now let me clear the implementation, when a new batch transaction takes
place, the data for this transaction get stored in the current Month
year table (for now XYZMast072005) and when we update this batch it
insert updated data in the same table (this is being done to keep the
History of previous data). Now the issue is the batch in the previous
Month Year table (for now XYZMast062005) can also be updated, hence
data grows in the same table. (We have managed the Primary key IDs, and
use a base id for each and every batch). So this is why it is not
possible to supply a fixed range on Primary key column on these tables.

I hope this will clear my stand.

Celko,
I always respect wisdom. and I can feel the a great source of
information in you as you talk about something like "design flaw" and
"old IBM mag tape file system labels" from which I am unaware of. Still
your comments sounds criticism, whereas I am looking for some help and
direction. Still thankful to you that you have provided atleast few
keywords, and my background processes are actively working on these.

Thanks for all of your typing efforts.

Jul 25 '05 #6
Zero.NULL (ma******@gmail .com) writes:
Erland, I apologize to use a regional unit here. Lac is equal to 0.1
Million

Now let me clear the implementation, when a new batch transaction takes
place, the data for this transaction get stored in the current Month
year table (for now XYZMast072005) and when we update this batch it
insert updated data in the same table (this is being done to keep the
History of previous data). Now the issue is the batch in the previous
Month Year table (for now XYZMast062005) can also be updated, hence
data grows in the same table. (We have managed the Primary key IDs, and
use a base id for each and every batch). So this is why it is not
possible to supply a fixed range on Primary key column on these tables.


I don't think so. It is not clear to me what your primary key is, but
it appears that it is (batchid, runningnumber). But you have fooled
yourself. Because in fact the primary key is (yearmonth, batchid,
runningnumber). You have hidden that first component of the key in
the table name. Thus, you need to add a column with yearmonth (that is
'200507', not '072005'!), then you can partition on that column.

However, now that I know what a Lac is, I would suggest that you should
leave this yearmonth-table business entirely. You get 200000-400000 rows
a month. That is not a threating size, and having one table per month
is definintely going to buy you more headache than it will save you from.
One table per year possibly, but not even 48 milliion rows really call
for a partition. It depends a little on what requirements for how long
you have to save the data.

I reckon that if most operations are against current month, it could
still be worthwhile to have an area for the current month. This can
be achieved in two ways. One is to have two tables, currentmonth and
archive. By the end of the month you move over the data from the
currentmonth table to the archive. You could unify the tables with a
partitioned view, assuming that you put a date first in the PK.

The other alternative would be to have all data in one table, but then
have an indexed view which is defined to hold the values of the current
month. Queries that are for current month only could go directly against
that view. Queries that are unlimited would go against the base table.
In this case, you would need a monthly job that drops the view and
recreates it with a new defintion. One thing which is appealing here is
that since the view would always be empty initially, this would not
require any data to be moved. (Not that moving half a million rows is
daunting.)

I should add, that all these designs I discuss here requires proper
indexing. Then again, if you were to search for data in your current
design, and you don't know which month to look in, you would have a hard
time to find what you are looking for.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 25 '05 #7
Thanks Erland, for providing such piece of information. I find these
designs really useful, as I was looking for a better design for it.

What i feel here was the lacking of proper knowledge of capabilities of
SQL server

As you say here:
However, now that I know what a Lac is, I would suggest that you should

leave this yearmonth-table business entirely. You get 200000-400000
rows
a month. That is not a threating size, and having one table per month
is definintely going to buy you more headache than it will save you
from.
One table per year possibly, but not even 48 milliion rows really call
for a partition. It depends a little on what requirements for how long
you have to save the data.

can you please guide me where can I get the white papers on SQL Server
capabilities (i.e. storage capacity of table)

thanks once again for your concerned and detailed mails on this issue.

Jul 25 '05 #8
Zero.NULL (ma******@gmail .com) writes:
can you please guide me where can I get the white papers on SQL Server
capabilities (i.e. storage capacity of table)


I will have to admit that I can't point directly to any such white
paper, but you may find something useful at
http://www.microsoft.com/technet/pro...l/default.mspx.

But as a general guidance, recall that SQL Server is designed to be
an enterprise solution. There are SQL Server databases out there with
over 10 TB of data. It goes without saying that an engine that is
capable to handle that amount of data, should not have any problem with
a couple of million rows.

That is, and this can not be stressed enough, proivided that you have
proper indexing.

I should also add that the number of rows is not really the crucial
part, but more the size in megabytes. If you have ten million rows, ir
makes quite a difference if your average row size is ten bytes or
7500 bytes.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 25 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
7287
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below. Specifically, I have a problem with this portion in the WHERE clause: DATEADD(Day,tblMyEventTableName.ReminderDays, @DateNow) Between CONVERT(smalldatetime,str(DATEPART(Month, @DateNow)+1) + '/' + str(DATEPART(Day, tblMyEventTableName.TaskDateTime)) + '/'...
20
5042
by: Laguna | last post by:
Hi Gurus, I want to find the expiration date of stock options (3rd Friday of the month) for an any give month and year. I have tried a few tricks with the functions provided by the built-in module time, but the problem was that the 9 element tuple need to be populated correctly. Can anyone help me out on this one? Thanks a bunch, Laguna
0
6437
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to be modified: if(e.CommandName =="Print") { string parsedreceipt = null; parsedreceipt = DecodeReceipt (e.Item.Cells.Text); Session = parsedreceipt;
3
2097
by: anthonybrough | last post by:
I have an asp page that has a form to collect user data in a form. when the user clicks submit the input is validated. If any fields are not acceptable the user clicks on a button to go back to the original form to correct the input. This all works fine until I try to incorporate a javascript to display a popup calendar which posts the selected date back to a field on the form. This script works fine in itself, however if the page is...
2
2713
cassbiz
by: cassbiz | last post by:
I am using strtotime and I have read up on some examples and am getting the wrong output, it jumps by several days instead of one day at a time. Ultimately what I am trying to accomplish is to set up an arrival time and a departure time for the script. This is using AJAX (which I am such a newbee @) from my earlier post http://www.thescripts.com/forum/threadnav583131-1-10.html Any help is greatly appreciated. <? $output = '';
7
3828
by: ajaydesai | last post by:
I have JavaScript code to dispaly two month calendar days at a time, but i have a problem both month that disaplay at a time have same days (for example May and June has same days, June and July have same days etc.) Instate of correct days. Here is my code from 3 files. *************************************************************************************** calendr.js file: isIE = (document.all ? true : false); isDOM =...
1
2620
osward
by: osward | last post by:
Hi everyone, Background 1. I have a table that consits 400+ rows of data and is growing by day. The table already has paging links at the bottom but I restricted to display rows of data only >= current date. Otherwise, user have to waste time to page up the pages to find the current date 2. I got a script of simple calendar from the web that use mktime() to create links on the calendar Task I need to let user view data earlier than...
2
1849
by: Skips | last post by:
Hi, I am trying to create a query where I can retrieve average monthly balances for a client for all the months that we have data stored for the year ending 2007. The table has a balance, for every business day of each month (AIGP_ENTRY_D) +- 24 entries per month. The result I need is a list of the month and the average balance for that month e.g. MNTH AVG_BAL ----- --------------- 01 1000.00...
1
3461
by: swethak | last post by:
hi, i have a code to disply the calendar and add events to that. It works fine.But my requirement is to i have to disply a weekly and daily calendar.Any body plz suggest that what modifications i have to made in my code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type"...
0
9303
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9117
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9894
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9679
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9676
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8542
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2508
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.