db:homework:answer2
作業2 參考解答
(e) Find those manufacturers that sell Laptops, but not PC's.
(1) Algebraic expression
<latex> \pi_{maker}(\sigma_{type=laptop}(Product) - \sigma_{type=pc}(Product)) </latex>
(2) Linear notation
<latex> R1:= \sigma_{type=laptop}(Product) </latex>
<latex> R2:= \sigma_{type=pc}(Product) </latex>
<latex> R3:= R1-R2</latex>
<latex> Answer:=\pi_{maker}(R3)</latex>
(g) Find those pairs of PC models that have both the same speed and RAM. A pair should be listed only once; e.g., list (i,j) but not (j,i).
(1) Algebraic expression
<latex> \pi_{R.model, S.model}(\sigma_{R.speed = S.speed \wedge R.ram=S.ram \wedge R.model < S.model}(\rho_{R}(PC) \times \rho_{S}(PC)))</latex>
(2) Linear notation
<latex> R:=PC </latex>
<latex> S:=PC </latex>
<latex> T:=\sigma_{R.speed = S.speed \wedge R.ram=S.ram \wedge R.model < S.model}(R \times S )</latex> or <latex> T:= R \bowtie\limits_{R.speed = S.speed \wedge R.ram=S.ram \wedge R.model < S.model} S </latex>
<latex> Answer:=\pi_{R.model, S.model}(T)</latex>
(i) Find the manufacturer(s) of the computer (PC or laptop) with the highest available speed.
(1) Algebraic expression
<latex> \pi_{maker}1)\bowtie\limits_{R3.speed<R4.speed} \rho_{R4}(\pi_{model,speed}(PC) \cup \pi_{model,speed}(Laptop)) ) ) \bowtie Product)</latex>
(2) Linear notation
<latex> R1:= \pi_{model,speed)(PC) </latex>
<latex> R2:= \pi_{model,speed)(Laptop) </latex>
<latex> R3:= R1 \cup R2 </latex>
<latex> R4(model,speed2):= R3</latex>
<latex> R5(model, speed):= \pi_{R3.model, speed} (R3 \bowtie\limits_{speed<speed2}R4)</latex>
<latex> R6:= R3 - R5 </latex>
<latex> Answer:= \pi_{maker}(R6 \bowtie Product) </latex>
(k) Find the manufacturers who sell exactly three different models of PC.
(1) Algebraic expression
<latex> \pi_{maker}(\sigma_{m1\neq m2 \wedge m1\neq m3 \wedge m2\neq m3}(\rho_{R1(maker, m1)}(\pi_{maker, model}(\sigma_{type=pc}(Product))) \bowtie \rho_{R2(maker, m2)}(\pi_{maker, model}(\sigma_{type=pc}(Product))) \bowtie \rho_{R3(maker, m3)}(\pi_{maker, model}(\sigma_{type=pc}(Product)))) - \pi_{maker}(\sigma_{m1\neq m2 \wedge m1\neq m3 \wedge m1\neq m4 \wedge m2\neq m3 \wedge m2\neq m4 \wedge m3\neq m4}(\rho_{R1(maker, m1)}(\pi_{maker, model}(\sigma_{type=pc}(Product))) \bowtie \rho_{R2(maker, m2)}(\pi_{maker, model}(\sigma_{type=pc}(Product))) \bowtie \rho_{R3(maker, m3)}(\pi_{maker, model}(\sigma_{type=pc}(Product))) \bowtie \rho_{R4(maker, m4)}(\pi_{maker, model}(\sigma_{type=pc}(Product)))) </latex>
(2) Linear notation
<latex> R1(maker, model1): \pi_{maker, model}(\sigma_{type=pc}(Product)) </latex>
<latex> R2(maker, model2):= R1 </latex>
<latex> R3(maker, model3):= R1 </latex>
<latex> R4(maker, model4):= R1 </latex>
<latex> R5(maker, model1,model2,model3):= R1 \bowtie R2 \bowtie R3 </latex>
<latex> R6(maker, model1, model2, model3, model4):= R4 \bowtie R5 </latex>
<latex> MThan3:=\pi_{maker}(\sigma_{model1\neq model2 \wedge model1\neq model3 \wedge model2 \neq model3} (R5)) </latex>
<latex> MThan4:=\pi_{maker}(\sigma_{model1\neq model2 \wedge model1\neq model3 \wedge model1 \neq model4 \wedge model2 \neq model3 \wedge model2 \neq model4 \wedge model3\neq model4} (R6)) </latex>
<latex> Answer(maker):=MThan3 - MThan4 </latex>
1)
R3 - \rho_{R5(model,speed)}(\pi_{R3.model,speed} ( \rho_{R3}(\pi_{model,speed}(PC) \cup \pi_{model,speed}(Laptop
db/homework/answer2.txt · 上一次變更: 2019/07/02 15:01 由 127.0.0.1