We consider a cognitive two-way relay network which consists of two transceivers (primary users) and multiple cognitive terminals. The two transceivers transmit their data toward the cognitive terminals which sense the spectrum constantly. If the primary users are in operation, the cognitive terminals act as relay nodes by multiplying the received signal by a beamforming coefficients and then broadcasting the soobtained signal to the transceivers. When the primary users are not in operation, the cognitive terminals communicate with a base station (BS) to increase the overall throughputs. Our aim is to optimally calculate the beamforming weight coefficients so as to minimize the total transmit power of the two transceivers and the cognitive radios subject to three constraints on the received signal-to-noise-ratios at the two transceivers and at the cognitive BS. Simulation results show that the sum-rate of the cognitive two-way relay network is increased while the total transmit power i...