I'm new to relational algebra and I need some help.

Let's say that I have 10 numbers : 1, 2, 3, 4.....9,10 which represent underground stations. How can I find which stations are close to station 8 (the answer should be 7 and 9).

The only comparisons that I know in RA are <, >, =, <=, >=, <>.
Can I have the above result (7,9) by using only these operations???

Thanks in advance

Well you know your boundaries, so you'll need to use those operators to check where the number falls between.
Have you ever done number lines in school?

Well you know your boundaries, so you'll need to use those operators to check where the number falls between.
Have you ever done number lines in school?

The problem is that I don't have a second number, in order to work between 2 numbers. Let's say that the numbers after 8 are infinite. How can I choose the one just next to 8.
Should I work between 8 and infinite?

So your range any positive value greater than zero?
As long as it is greater than zero(n > 0), then it should be obvious what the number falls between.

Your replies are too laconic!!!!
Could you please be more specific.
It has been 16 years since I finished school. I attend an open University which means that we have meetings once a month, I can't contact my teacher for the last 3 days, and I'm really loosing my mind.
Nevertheless thanks for your intention to help!


P.S. Is it O.K. to use "+" in Relational Algebra. Could we say for example >8+1?

Well, I'm hardly older than 16, obviously not a math teacher, and this is voluntary so I don't have much obligation.

First look at this number line.
Put an line at zero and ignore the negatives.
Consider this pseudo-code:

if n < 1 then it's invalid
else if n == 1 then solve for right
else then solve for right(addition) and left(subtraction)

I assume addition, and subtraction is valid, since it's just a number of a position.

Well, I'm hardly older than 16, obviously not a math teacher, and this is voluntary so I don't have much obligation.

First look at this number line.
Put an line at zero and ignore the negatives.
Consider this pseudo-code:

if n < 1 then it's invalid
else if n == 1 then solve for right
else then solve for right(addition) and left(subtraction)

I assume addition, and subtraction is valid, since it's just a number of a position.

Thanks for once more, I didn't mean that you are obliged to answer, I just wanted to mention that I'm not just a kid that is trying to find someone to solve my exercises (I'm 34, I finished highschool in 1992).

My problem is that there is no example in relational algebra that uses "+" and "-", also there are no "else if" or "if" in relational algebra. Non of my fellow students has resolve this one and I'm really pissed off that I can't contact my teacher. That's all.
Never mind, thanks once again for trying to help!

I think we can safely conclude that MosaicFuneral has no idea what he's talking about.

I don't either, but why can't you just select the elements equal to 7, select the elements equal to 9, and union these two sets?

Thank you, this is probably the answer (I finally did contact my teacher and advised me the same things with you), but I was expecting something more complex and clever that could be used in many situtations.
This kind of solution sounds a little silly to me, but this is how relational algebra works.
Thanks again!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.