# Table scheme question

**URL:** <https://www.ruby-forum.com/t/table-scheme-question/196522>\
**Category:** Rails\
**Created:** [November 20, 2007, 10:12am UTC](https://www.ruby-forum.com/t/table-scheme-question/196522 "2007-11-20T10:12:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [November 20, 2007, 10:12am UTC](https://www.ruby-forum.com/t/table-scheme-question/196522/1 "2007-11-20T10:12:58Z")

</div>

Hi…

I am getting grey hair…i don’t now the right setup for the solution.  
Maybe you can help?..

Concept.

companyX has for each period (1 year, 2 years ect) different 5  
values…

So for example:  
2 years…has the value rates of 3%, 4%, 6%, 7%  
5 years…has the value rates of 4%, 6%, 6%, 9%

Can anyone help how my table scheme looks like…or multiply tables??

remco

---

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [November 20, 2007, 11:05am UTC](https://www.ruby-forum.com/t/table-scheme-question/196522/2 "2007-11-20T11:05:43Z")

</div>

On Tue, 20 Nov 2007 01:11:51 -0800,  
removed\_email\_address@domain.invalid wrote:

> Hi…
> 
> I am getting grey hair…i don’t now the right setup for the solution.  
> Maybe you can help?..
> 
> Concept.
> 
> companyX has for each period (1 year, 2 years ect) different 5  
> values…

when I hear “five values” I think “five fields”. Or, in ruby, five  
attr\_accessors, or five instance variable.

I think of the periods as either records or rows, or, in ruby: objects  
(if that helps).

> So for example:  
> 2 years…has the value rates of 3%, 4%, 6%, 7% 5 years…has the value  
> rates of 4%, 6%, 6%, 9%

That’s the desired output? It’s not meaningful to me; I have no idea  
what that’s supposed to convey. Do you want:

2 years rates in percentages : 3,4,6,5  
5 years rates in percentages : 4,6,6,9

If so, why? What does it mean? A five year loan at four percent? or  
six  
percent? Which one?

> Can anyone help how my table scheme looks like…or multiply tables??
> 
> remco

table: quarters

year quarter  
2007 1  
2007 2  
…

table: rates

rate  
3  
5  
5  
6

one-to-many relation between “quarters” and “rates” so that query  
results  
are along the lines of:

year quarter rate  
2007 1 3  
2007 1 4  
2007 2 5

However, that doesn’t make sense to me because _why_ would there be:

2007 quarter 1 3% rate  
2007 quarter 1 4% rate

Also, it’s kind of silly to have a “rates” table which just has a list  
of  
integers, but the alternative is to put the year and quarter into one  
field giving:

# year & quarter rate

2007 1 3  
2007 1 3  
7007 2 5

this doesn’t make sense to me, it’s like a store giving two different  
prices for the same product at exactly the same time. Or, what would be  
the reason for two different rates for the same quarter? Maybe another  
field is required.

What is your desired output? Please be specific, maybe give a concrete  
example 🙂

is there rate1, rate 2, …, rate 5? These are the five values? prime  
rate, not-so-prime and so on?

-Thufir

---

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [November 20, 2007, 11:29am UTC](https://www.ruby-forum.com/t/table-scheme-question/196522/3 "2007-11-20T11:29:29Z")

</div>

Thufir wrote:

> On Tue, 20 Nov 2007 01:11:51 -0800,  
> removed\_email\_address@domain.invalid wrote:
> 
> > Hi…
> > 
> > I am getting grey hair…i don’t now the right setup for the solution.  
> > Maybe you can help?..
> > 
> > Concept.
> > 
> > companyX has for each period (1 year, 2 years ect) different 5  
> > values…
> 
> when I hear “five values” I think “five fields”. Or, in ruby, five  
> attr\_accessors, or five instance variable.
> 
> I think of the periods as either records or rows, or, in ruby: objects  
> (if that helps).
> 
> > So for example:  
> > 2 years…has the value rates of 3%, 4%, 6%, 7% 5 years…has the value  
> > rates of 4%, 6%, 6%, 9%
> 
> That’s the desired output? It’s not meaningful to me; I have no idea  
> what that’s supposed to convey. Do you want:
> 
> 2 years rates in percentages : 3,4,6,5  
> 5 years rates in percentages : 4,6,6,9
> 
> If so, why? What does it mean? A five year loan at four percent? or  
> six  
> percent? Which one?
> 
> > Can anyone help how my table scheme looks like…or multiply tables??
> > 
> > remco
> 
> table: quarters
> 
> year quarter  
> 2007 1  
> 2007 2  
> …
> 
> table: rates
> 
> rate  
> 3  
> 5  
> 5  
> 6
> 
> one-to-many relation between “quarters” and “rates” so that query  
> results  
> are along the lines of:
> 
> year quarter rate  
> 2007 1 3  
> 2007 1 4  
> 2007 2 5
> 
> However, that doesn’t make sense to me because _why_ would there be:
> 
> 2007 quarter 1 3% rate  
> 2007 quarter 1 4% rate
> 
> Also, it’s kind of silly to have a “rates” table which just has a list  
> of  
> integers, but the alternative is to put the year and quarter into one  
> field giving:
> 
> # year & quarter rate
> 
> 2007 1 3  
> 2007 1 3  
> 7007 2 5
> 
> this doesn’t make sense to me, it’s like a store giving two different  
> prices for the same product at exactly the same time. Or, what would be  
> the reason for two different rates for the same quarter? Maybe another  
> field is required.
> 
> What is your desired output? Please be specific, maybe give a concrete  
> example 🙂
> 
> is there rate1, rate 2, …, rate 5? These are the five values? prime  
> rate, not-so-prime and so on?
> 
> -Thufir

Hi Thufir

> That’s the desired output? It’s not meaningful to me; I have no idea  
> what that’s supposed to convey. Do you want:

> 2 years rates in percentages : 3,4,6,5  
> 5 years rates in percentages : 4,6,6,9

> If so, why? What does it mean? A five year loan at four percent? or  
> six  
> percent? Which one?

When you decide as a consumer to get a loan…in the dutch market…there  
are 3 choices you must take;

1:The lender.  
2:the period(1 year fixed, 2 year ect)  
3:and the EW\*\*

\*\*The EW has todo with the risk tou want to take.

Example:

Lender MortgageCompanyA has:

1 year (fixed) the rates are:  
EW1 = 4.5%  
EW2 = 4.6%  
EW3 = 4.7%  
EW4 = 4.9%

2 year (fixed) the rates are  
EW1 = 4.5%  
EW2 = 4.6%  
EW3 = 4.9%  
EW4 = 5.9%

ect.

Lender MortgageCompanyB has:

1 year (fixed) the rates are:  
EW1 = 4.7%  
EW2 = 4.9%  
EW3 = 5.1%  
EW4 = 6.0%

2 year (fixed) the rates are  
EW1 = 6.0%  
EW2 = 6.6%  
EW3 = 6.9%  
EW4 = 6.9%

Example, check \>  
[http://www.renteoverzicht.nl/hypotheekrenteoverzicht.php](http://www.renteoverzicht.nl/hypotheekrenteoverzicht.php)

The example is also my desired output…

Thanks…Thufir…i am a newbie…it would be great if you can help  
me…

---

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [November 21, 2007, 2:59am UTC](https://www.ruby-forum.com/t/table-scheme-question/196522/4 "2007-11-21T02:59:50Z")

</div>

On Tue, 20 Nov 2007 11:29:29 +0100, Remco S. wrote:  
[…]

> Example, check \>  
> [http://www.renteoverzicht.nl/hypotheekrenteoverzicht.php](http://www.renteoverzicht.nl/hypotheekrenteoverzicht.php)  
> […]

table: five year

# lender NHG rate1 rate2 rate3 rate4

lender1 4.55 4.75 4.85 4.85 4.95  
lender2 3.55 6.75 4.85 4.85 4.95  
lender3 5.55 3.75 4.85 4.85 4.95

table: ten year

# lender NHG rate1 rate2 rate3 rate4

lender1 4.55 4.75 4.85 4.85 4.95  
lender2 3.55 6.75 4.85 4.85 4.95  
lender3 5.55 3.75 4.85 4.85 4.95

Because I’m lazy, I used the same data 🙂

so, this design would suck because it’s redundant, requiring massive  
data  
entry with many opportunities for data entry errors – very tedious.

Nothing jumps out at me, so let’s gather more data. What does NHG mean?

Now, how are these numbers calculated? Which are dependant, which are  
independant?

Can this be pared down to lender, NHG and term?

And then there’s arithmetic to generate:

# lender NHG rate1 rate2 rate3 rate4 term in years

lender1 4.55 4.75 4.85 4.85 4.95 1

where rate1 to rate4 are calculated?

Even better, can the rates be calculated?

If so, the only data which is stored is:

# lender NHG

lender1 4.55  
lender2 5.22  
lender3 4.39

so that there’s a function “rates” which returns rate1, rate2, rate3,  
rate4 given an NHG and term? As a starting point, there could be four  
formulas. Either a sort of “vector valued function” which returns an  
array [4.75 4.85 4.85 4.95] or four functions to calculate each  
of those elements. Either approach is fine.

I think it depends on how the calculations are made. It may be that  
only  
two columns are required: lender name and NHG.

-Thufir
