We have now built up enough background to study what economists call "industrial organization" -- that is, the study of industries, including their organization and structure, how they conduct business, how they respond to change and evolve, and how efficiently they perform.
Economists believe all these things are interrelated, so this is sometimes called a structure/conduct/performance approach.
As usual, the first step will be some terminology. Economists in general recognize four major types of market structures (plus a larger number of subtypes):
For now, I will just define the first of the four, and then use concepts related to "Perfect Competition" to define the other three.
What many economists call "Perfect Competition" is an idealized structure of an industry in which price competition is dominant -- in fact the only form of competition possible. The terminology "Perfect Competition" is quite common but not quite universal. The term "Pure Competition" is also sometimes used. I will use the term "P-Competition," where the P can stand for perfect, pure, or price competition -- whichever you like.
A P-Competitive structure is defined by four characteristics. For an industry to have a P-competitive structure, it must have all four of these characteristics:
These are all characteristics that favor price competition. Each of these characteristics will be explained in turn.
If there are "many small sellers," it makes it much harder for any seller or any group of sellers to "rig the price." Similarly, if there are "many small buyers," there is little opportunity for buyers to "rig the price" in their own favor. These conditions encourage the buyers and sellers in the market not even to try to control the price, but instead to compete against one another whenever quantity supplied differs prom quantity demanded, driving the price toward the equilibrium of supply and demand.
"Homogenous products" means all suppliers sell products that are perfect substitutes. If different sellers sold different products, then customers might be reluctant to switch suppliers when one supplier raises the price. They might stick with the supplier even at the higher price, because, even at the higher price, they like the product of that firm better than the product of another firm. By ruling this out, the homogeneity of products encourages price competition.
Some versions of the "perfectly competitive" structure include "perfect knowledge" as one of its characteristics -- but, of course, "perfect knowledge" never exists in reality. All the same, traders need to know quite a bit to compete effectively in markets. They need to know the terms on which other people are offering goods and services, or offering to buy; the quality of the goods and services offered, and enough about costs to judge whether the trade is profitable or not. This is what I mean by "sufficient knowledge"
Remember Adam Smith's concept of the "natural price:" when the price of beer is high, so that brewing is especially profitable, people will enter the brewing trade and their competition with the established breweries will force the price down toward the "natural" price. As Smith was aware, in the long run the entry of new competition -- or the exist of unprofitable firms from the industry, to go into other trades -- is one of the most important aspects of competition and is thus one of the four characteristics of the P-competitive structure.
The other three market structure models can be defined in terms of the ways in which they deviate from the characteristics of P-Competition.
In a Monopoly there is just one seller of a good or service for which there is no close substitute.
In an oligopoly there are two or more, but only a few firms.
In Monopolistic Competition, the products are not homogenous but are "differentiated." We don't have a standard model for "insufficient knowledge" but, at least in some cases, that seems to work similarly to "product differentiation."
Our next step is to explore the operation of a firm in a P-Competitive industry. To be specific, what does the demand curve for the individual firm look like? We have already noticed, some time back, that the individual firm's demand curve is different from that of the industry, and is more elastic. This is because substitutes increase elasticity, and the customer of the firm has many good substitutes for that furm's output -- namely, the output of other firms in the industry. Let's go back through the four characteristics of the P-Competitive industry structure, and see how they influence the elasticity of the individual firm's demand.
Here are the basics:
Since a P-Competitive structure is an idealization of these tendencies, we say that the demand curve for a P-Competitive firm is infinitely elastic. In fact the demand curve for a P-Competitive Firm is a horizontal line corresponding to the going price. And that makes sense, because the price in a P-Competitive market is determined by supply and demand -- not by the seller or the buyer. Conversely, so far as the seller or the buyer is concerned, the price must be a given, since it is determined by supply and demand. Economists sometimes express this by saying that the price is "parametric," meaning that while it may change from time to time, it does not change in response to the firm's output decision.
Happily -- but not by coincidence! -- all of our examples of profit maximization to date are based on the assumption of given prices. Thus, we already know that the supply curve of a P-Competitive firm is the firm's marginal cost curve. Thus, marginal cost = price is the same as quantity supplied = quantity demanded for the individual firm. When marginal cost = price for each firm in the industry, we have quantity supplied = quantity demanded in the industry as a whole. Here's a picture:
In the figure, the lower case q, s and d refer to output, supply and demand from the point of view of the individual firm, respectively, and the capital S, D, and Q are for the industry as a whole. Price (per unit sold) is the same from all points of view. 
We notice that, in the picture just shown, the firm is making an "economic profit." All costs, explicit and implicit, are included in the firm's Average Cost curve. In particular, Average Cost includes the opportunity cost of capital investment -- so another way of putting it is that investors in this industry are making more than their best alternative investment in any other industry. These profit opportunities will attract new firms into the industry. With "free entry," the (short run) supply curve of the industry shifts to the right, causing the price to drop until the economic profits are eliminated. This process of entry and price change is known as the "long run equilibrium process" and it continues until "long run equilibrium" is attained. Here is a picture of the firm and industry in "long run equilibrium:"
The new price, quantity, firm demand and short run supply are indicated by primes -- p', q'. Q', d', S'. We see that, at a slightly lower price, the individual firm is lower on the MC curve and produces a little less, but since there are more firms in the industry, the industry as a whole produces more. 
We notice something else about the long-run equilibrium of a P-Competitive industry: each firm chooses the plant and equipment and productive capacity that gives the lowest average cost overall. This is shown by the above figure. 
This applies to any economic activity to which there is "free entry."
The conduct and performance of an industry will depend to some extent on its structure. Among four major types of structures recognized by economists we have focused on the P-Competitive -- sometimes called Perfectly or Purely Competitive -- structure as the one corresponding most closely to the supply and demand model. We have found that the P-competitive model defines a kind of ideal in which rational self-interest leads to an allocation of resources in which the efficient quantities of outputs are produced by enterprises of an efficient cost-minimizing scale. This remarkable finding is a modern counterpart to Adam Smith's conception of the "invisible hand."