think of the discrete sum as:
SUM (from i=0 to n) of [f(x)*1].
that's what it is, you re sampling f(x) at integer values of x, and multiplying each value by the distance between samples, 1, to give you the area under a step-approximation to the function f(x).
Now think about SUM(i=0, 0.5, 1, 1.5, ..., n-0.5, n) of [f(x)*0.5]
That is a better approximation to the area under the curve, because you're using twice the number of samples. The integral is the limit of this to infinity.
INT(from 0 to n) of f(x) dx = limit as δx-->0 of SUM(i=0, δx, 2δx, ... n-δx, n) of [f(x)*δx]
Basically you're adding an infinite number of infinitely thin blocks, to get an exact value for the area underneath. And the principles of calculus shows that the integral of f(x)*dx is the antiderivative of f(x), so you use the same rules as differentiation but backwards.You can write down any function to integrate, but in some cases it won't make sense. In the case you suggest, f(x) = 5, it is simple and the area underneath is infinite for your stated domain.
The derivative is the slope of the tangent line to the curve.