This diagram is of the electron orbital notation of calcium. The electron shells would just be the boxes that have the same number for example, there is 2s and 2p. Together they form an electron shell. In order to move onto another electron shell the ones before it must be filled. The way that you fill incomplete electron shells is to first put an "up" arrow in each of the boxes, and then you would start filling in the "down" arrows. Notice how the outermost electron shell, 4s, is filled (meaning that there are two arrows, which represent electrons, in each individual box)? That means that calcium is a stable element. The following diagram is the electron orbital notation for oxygen.
The outermost electron shell is not filled in this element. That means that oxygen is not a stable element.
The main reason that atoms form bonds is to achieve stability. In fact, the definition of compound is: when two or more atoms chemically bond together, which implies that a certain elements are only compounds when two or more of its atoms are chemically bound together. In the year of 1916, an American chemist by the name of Gilbert Lewis came up with a theory. His theory was that atoms form chemical bonds with each other because their electrons interact with other electrons from other atoms. They interact to fill its outermost energy level to create a stable product. To make things a little more clear, there is a diagram below.
How do name salts?
What is a polyatomic ion?
How are molecules specified?