What is a complex sentence?
A complex sentence consists of one independent clause, and one or more dependent clauses. The clauses are connected through either a subordinate conjunction or a relative pronoun. The dependent clause may be the first or second clause in the sentence. If the first clause in the sentence is dependent, a comma usually separates the two clauses.

Example #1:

When it started raining, we had to go inside.

Independent clause Dependent clause

We had to go inside when it started raining.

The independent clause comes first, and is linked to the subordinate (dependent) clause with the subordinating conjunction "when."

Example #2:

I will stay indoors and play if it rains.

Dependent clause Independent clause

If it rains, I will stay indoors and play.

The dependent clause is in first position, so there is a comma separating the two. The dependent clause begins with the subordinating conjunction "as long as."

COMMON SUBORDINATE CONJUNCTIONS. because, since, as, when, if, although, while, even though, whenever, [before, after]

Reminder:
Compound Sentence: at least two independent clauses; no dependent clauses.

Example:

He finally read the book , and his mother returned it to the library..

The two independent clause are joined by a comma and the coordinating conjunction "or." [and, but, or, so, yet]