【正文】
ice from goods g,category c where = and =39。 π gname,unit,price(σ = ^ame=‘食品 ’ ( goods category) ) DML和關(guān)系代數(shù)表達(dá)式 完成下列查詢要求,寫出對應(yīng)的 SQL語句及關(guān)系代數(shù)表達(dá)式 。 select , , from goods g, buyer b, orders o, detail d where = and = and = and =39。 π gname, counts, price ( σ = ^ = ^ = ^ =39。 ( goods buyer orders detail)) DML和關(guān)系代數(shù)表達(dá)式 完成下列查詢要求,寫出對應(yīng)的 SQL語句及關(guān)系代數(shù)表達(dá)式 。 (本小題不用寫關(guān)系代數(shù)) select , from buyer b where in (select from orders o,detail d,goods g where = and = and (=39。 or =39。)) view ? 編寫 1個視圖,按商品類別分類統(tǒng)計出所有商品 2022年之前的銷售數(shù)量、銷售額,視圖列集包括類別名、銷售數(shù)量、銷售金額。 create view v_sales_sum2 (ame, count_c, sum_c) as Select , count(), sum(*) From category, goods, detail,orders Where = and = and = and year() =39。 group by , procedure 編寫 1個存貯過程,完成往指定訂單中添加商品的操作業(yè)務(wù),輸入?yún)?shù)包括訂單編號、商品編號、購買數(shù)量,需要檢查訂單編號、商品編號是否存在。( 10分) create procedure prg_ins_detail ono varchar(16), gno char(10), counts int as declare price numeric(6,1)。 if not exists(select gno from goods where gno=gno) return 6002。 insert into detail (ono,gno,counts,price) values (ono,gno,counts,price)。2022121519430239。g02439。 trigger 編寫 1個觸發(fā)器,完成訂單表中總金額的自動累計功能,即通過訂單明細(xì)中商品的價格與數(shù)量自動統(tǒng)計訂單中的總金額。( 10分) create trigger tri_detail_ins on detail for insert as declare ono varchar(16),money numeric(6,1) select ono=ono ,money=counts*price from inserted。 go exec prg_ins_detail 39。,39。