In national accounts, the trade deficit represents the negative balance of the trade balance. In other words, a "deficit" is generated in the trade balance when imports exceed exports. In the opposite case (exports exceeding imports) we talk about "commercial surplus".
The trade balance records a "breakeven", however, when the balance is 0 (exp-imp=0).
Naturally, the exchange rate plays a predominant role in the formation of a deficit (as well as a surplus). To simplify, a devalued exchange rate tends to favor exports; otherwise, an overvalued exchange rate tends to penalize exports and favor imports, hence the deficit.