Better bound for integral inequality

Let $$f:[a,b] \rightarrow \mathbb{R}$$ with $$f \in C^1$$ and $$f(a)=0$$. We want to show that $$\int_{a}^{b}f^2(x)\mathrm{d}x \leq (b-a)^2\int_{a}^{b}[f'(x)]^2\mathrm{d}x$$

There is a hint namely to consider $$f(x)=\int_{a}^{x}f'(t)\mathrm{d}t$$ because $$f(a)=0$$ and then use the Cauchy-Schwarz inequality for integrals.

So I tried doing the following: $$f^2(x)=\left ( \int_{a}^{x}f'(t)\mathrm{d}t \right )^2\leq\left ( x-a \right )\int_{a}^{x}\left [ f'(t) \right ]^2\mathrm{d}t\leq\left ( b-a \right )\int_{a}^{b}\left [ f'(t) \right ]^2\mathrm{d}t$$

and finally integrate the expression with respect to $$x$$ over $$[a,b]$$. My first question is whether my approach has any mistakes (I am mainly worried since in the textbook the last inequality has $$x$$ as instead of $$b$$ as the higher bound of integration and I am wondering whether it is a mistake, because when integrating again the result only follows if the integral in the last inequality is independent of $$x$$) and whether this this strategy works in general with higher powers of functions and their derivatives (for example using some variation of the Hölder inequality or something).

Then there is a challenge without hint or solution that asks us to prove that there is a smaller upper bound, namely $$\int_{a}^{b}f^2(x)\mathrm{d}x \leq \frac{(b-a)^2}{2}\int_{a}^{b}[f'(x)]^2\mathrm{d}x$$

Here I got stuck. I tried the same approach $$f^2(x)=\left ( \int_{a}^{x}f'(t)\mathrm{d}t \right )^2\leq\left ( x-a \right )\int_{a}^{x}\left [ f'(t) \right ]^2\mathrm{d}t$$ and I tried finding a number $$x$$ such that $$x-a=\frac{b-a}{2}$$ which means $$x=\frac{b+a}{2}$$ so that I can say $$\left ( x-a \right )\int_{a}^{x}\left [ f'(t) \right ]^2\mathrm{d}t\leq\left ( \frac{b-a}{2} \right )\int_{a}^{\frac{b+a}{2}}\left [ f'(t) \right ]^2\mathrm{d}t$$ and then integrate to get the desired result (as integration over $$[a,b]$$ would just multiply the right hand side with $$b-a$$ and we would be done). However this only works when $$x\in [a,\frac{b+a}{2}]$$ and I cannot seem to find a way to prove it for the rest of the interval. So how do I proceed here?

Finally, as I am new to integral inequalities, any suggestions on how one should study to learn how to solve basic problems or where to study from are welcome. Thanks in advance!

For the second one: As you already showed, the inequality $$f^2(x)=\left ( \int_{a}^{x}f'(t)\mathrm{d}t \right )^2\leq\left ( x-a \right )\int_{a}^{x}\left [ f'(t) \right ]^2\mathrm{d}t$$ holds. Now use this inquality inside the integral and integrate by parts \begin{align} \int_{a}^{b}f^2(x)\mathrm{d}x&\leq \int_{a}^{b}\left (\left ( x-a \right )\int_{a}^{x}\left [ f'(t) \right ]^2\mathrm{d}t\right )\mathrm{d}x\\& =\frac{(b-a)^2}{2}\int_{a}^{b}\left [ f'(t) \right ]^2\mathrm{d}t-\int_{a}^{b}\frac{(x-a)^2}{2}\left [ f'(x) \right ]^2\mathrm{d}x\\& \leq \frac{(b-a)^2}{2}\int_{a}^{b}\left [ f'(x) \right ]^2\mathrm{d}x. \end{align} Here we have used that one term disappears while partial integration and the integrands of the term with the minus sign are all greater than zero for the last inequality.