473,386 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

table design - varying contract rates

2
Hello

I am looking for some help with table structure design, i am creating a database which manages data on loft and cavity wall insulation done by various contractors. The database uses look up tables to work out how much energy is expected to be saved over the lifetime of the householder in GWh by the individual measure installed using data like the type of house and the type of fuel used to heat the home. The monetary value of the work is actually worked out on the basis of the GWhr's saved.

At the moment there is a single table TBL_Agreements which holds the information relevant to the contracts we have with our partners who do the actual work and recieve payment from us. There are two types of work, PG and ATP and the table has two important fields PoundsPerUnitPG and PoundsPerUnitATP. The monetary value of the work is then easily worked out by multiplying the number of energy units (GWhr's) by the appropriate pounds per unit figure.

Now the situation has been made slightly more complicated our partners are being offered incentive rates for the PG work because we aren't getting enough of it. This is being offered in the form of a bonus so they get (say) 7500 £/GWh up to x GWh, then 8000 £ / GWh up to y GWhrs then 8500 £/GWh after that. I'm am wondering how to implement this in the database and the idea I have come up with is to have a table TBL_Rates which is linked to TBL_Agreements in a one to many relationship so one agreement can have many rates (or it could of course only have one and that special case would be the old style flat rate £/GWh agreement).

My original table had the following fields:

IDAgreement (autonumber primary key), IDAgent (foreign key to agents - read contractors, table), IDScheme (another foriegn key), Agreement (text label, name for the agreement), PoundsPerUnitPG, PoundsPerUnitATP, PercentPG (how much of the work in total must be PG by the end of the contract term), FromDate, TermInMonths, BudgetPG (in energy units), BudgetATP, BudgetUnit(the energy unit GWhrs or CarbonTonnes), Notes, FixedPriceAgreement (don't worry about this for now it just makes it more complex).

Now I am thinking of basically taking PoundsPerUnitPG and PoundsPerUnitATP and putting them in this new linked table TBL_Rates along with also a FromDate and ToDate (though FromDate and Term would also stay in TBL_Agreements) and also a FromGwhrs and ToGWh's then when the data is imported i can calculate the GWh's saved as usual and then work out with a query which band i need to use to calculate the moneys

just wondering if this sounds like a good idea to the more experienced posters amongst us or if someone has done anything similar and has a better way.
Oct 8 '07 #1
1 1548
nico5038
3,080 Expert 2GB
I would construct besides the standard tblRates I would define a table holdong the Bonus.
Reason for this is the fact that the bonus can vary and having it recorded in a table will allow easy updates. Even when the rates should be recorded depending on a specific period, this will allow the addition of a validity date.

The tblBonus would hold:
WorkType (PG or ATP just in case this is added in the future)
LimitStart (Lower GWh starting with 0 )
LimitEnd (Higher GWh ending with 9999999999)

As a range is always needed, also the 8500 and higher will have to get an upper limit, being the max value the number field can hold.

For extracting the needed Pounds you can use a JOIN where the calculated GWh us used and looks like:
WHERE GWhOrder Between LimitStart and LimitEnd

Getting the idea ?

Nic;o)
Oct 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

22
by: Bryan Guilliams | last post by:
I'm trying to come up with an elegant, simple way to compare two consecutive values from the same table. For instance: SELECT TOP 2 datavalues FROM myTable ORDER BY timestamp DESC That...
36
by: toedipper | last post by:
Hello, I am designing a table of vehicle types, nothing special, just a list of unique vehicle types such as truck, lorry, bike, motor bike, plane, tractor etc etc For the table design I am...
6
by: Jeff Kowalczyk | last post by:
I need to adapt this an update statement to a general form that will iterate over multiple orderids for a given customerinvoiceid. My first concern is a form that will work for a given orderid,...
5
by: Stewart Allen | last post by:
Hi all, I'm designing a club database and have encountered a problem when trying to extract the total amount of fees that a Student/Family is suppose to pay during their time of membership. I've...
8
by: gacuna | last post by:
i want to insert into a temporal table the result of a store procedure. on sql server the sentence would look like this (already working) INSERT INTO #SHIPINFO exec TESTDTA.S59RSH05 @SCBILLTO,...
9
by: PeteCresswell | last post by:
I've got something called "Reference Rates". The idea is that on a given day, we have various rates of return for various entities. e.g. Libor 3-month return, Libor 6-month return, US Treasury...
10
by: antheana | last post by:
Hi there, I am currently redesigning a database, which includes a contracts table that captures information about each contract e.g. ContractID (PK) ContractReference ContractTypeID (FK) ...
2
by: tasmontique | last post by:
I am working on an access 2002 flight schedule database. I am new to access but have some basic understanding of sql and vb6 code. I have learned a lot from this website. Thanks much Hopefully...
29
by: Brad Pears | last post by:
Here is a simple OO design question... I have a Contract class. The user can either save an existing contract or they start off fresh with a blank contract, fill in the data and then save a...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...
0
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...

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.