How to show the two definitions of $\mathcal O_S$-algebra are equivalent?

Let $$(S,\mathcal O_S)$$ be a scheme. What's the definition of $$\mathcal O_S$$-algebra?

It's a sheaf $$\mathcal{A}$$ of $$\mathcal{O}_S$$-modules on $$S$$ which is also a sheaf of rings, such that the $$\mathcal{O}_S$$-module map $$\mathcal{O}_S \to \mathcal{A}$$ induced by $$1 \mapsto 1$$ is a ring map. (Equivalently, a sheaf of rings $$\mathcal{A}$$ on $$S$$ together with a ring homomorphism $$\mathcal{O}_S \to \mathcal{A}$$.)

How to show the above two definitions are equivalent?

The $$\mathcal{O}_S$$-module map $$\mathcal{O}_S \to \mathcal{A}$$ induced by $$1 \mapsto 1$$ is a ring map, we denote it by $$f$$. For any open subset $$U$$ of $$S$$, $$f(U): \mathcal O_S(U)\to \mathcal A(U)$$, $$\forall t\in \mathcal O_S(U),x\in \mathcal A(U)$$, how to show $$tx=f(U)(t)x$$?

• Do you understand the result for algebras over a ring? A set $A$ is said to be an algebra over a ring $R$ of $A$ admits an $R$-module structure together with a compatible ring structure. Equivalently, the algebra structure on $A$ can be described by a ring structure on $A$ together with a ring map $R \to A$. – Sofie Verbeek Oct 17 '18 at 17:09
• Now apply this description for every open $U$. The set $\mathcal{A}(U)$ is an $\mathcal{O}_S(U)$-algebra if it is a ring with a compatible $\mathcal{O}_S(U)$-module structure, or equivalently, if it is a ring together with a ring morphism $\mathcal{O}_S(U) \to \mathcal{A}(U)$. – Sofie Verbeek Oct 17 '18 at 17:10
• Which would lead to yet another representation: an $\mathcal{O}_S$ algebra would be a function which for every open $U$, gives an $\mathcal{O}_S(U)$-algebra $\mathcal{A}(U)$, along with restriction maps $\mathcal{A}(U)\to \mathcal{A}(V)$ for each pair $V \subseteq U$, such that for any $x \in \mathcal{O}_S(U)$, $a \in \mathcal{A}(U)$, we have $(a \cdot x)|_V = (a|_V) \cdot (x|_V)$ (and also $(x \cdot a)|_V = (x|_V) \cdot (a|_V)$ if we allow sheaves of non-commutative algebras). – Daniel Schepler Oct 19 '18 at 19:31