Y
_yzy_
Unregistered / Unconfirmed
GUEST, unregistred user!
/*Table :品名表 Owner: WXF*/<br>Create Table Commodity_Table<br>(<br> C_IDSTR DoMain_6 not null,<br> C_Name DoMain_20 not null, <br> Primary key (C_IDSTR)<br>);<br>--------------------------------------------------<br><br>/*Table :类别表 Owner: WXF*/<br>Create Table C_Type<br>(<br> C_TypeID DoMain_6 not null,<br> C_TypeName DoMain_20 not null,<br> C_ParentField DoMain_6 not Null,<br> Primary key (C_TypeID)<br>);<br>-----------------------------------------------<br>/*Table :发出表 SendCoupons_Table*/<br>Create Table SendCoupons_Table<br>(<br> C_ID DoMain_10 not null, /*编号*/<br> C_TypeID DoMain_6 not null, /*类型*/<br> S_SendD DoMain_Date, /*发出日期*/<br> S_FaceValue DoMain_Currencies,/*面值*/<br> S_EndD DoMain_Date, /*截止日期*/<br> S_RecipientsCompany DoMain_50, /*领用单位*/<br> S_Flag DoMain_10, /*记号*/<br> S_Memo DoMain_50 /*备注*/<br> C_IDSTR DoMain_50 /*品名*/ <br>);<br>ALTER TABLE SendCoupons_Table ADD CONSTRAINT PK_SendCoupons_Table PRIMARY KEY (C_ID,C_TypeID);<br>ALTER TABLE SendCoupons_Table ADD CONSTRAINT FK_SendCoupons_Table FOREIGN KEY (C_TypeID) REFERENCES C_Type (C_TypeID)<br>ON DELETE CASCADE<br>ON UPDATE CASCADE;<br>-----------------------------------------------------<br>/*Table :回收表 Owner: WXF*/<br>Create Table RecoveryCoupons_Table<br>(<br> C_ID DoMain_10 not null, /*编号*/<br> C_TypeID DoMain_6 not null, /*类型*/<br> R_SendD DoMain_Date, /*回收日期*/<br> S_Memo DoMain_50 /*备注*/<br>);<br>ALTER TABLE RecoveryCoupons_Table ADD CONSTRAINT PK_RecoveryCoupons_Table PRIMARY KEY (C_ID,C_TypeID);<br>ALTER TABLE RecoveryCoupons_Table ADD CONSTRAINT FK_RecoveryCoupons_Table FOREIGN KEY (C_TypeID) REFERENCES C_Type (C_TypeID)<br><br>********************************************<br>*****************实例数据********************<br>/*Table :类别表 C_Type*/<br>C_TypeID C_TypeName<br>10 A类<br>11 B类<br>-----------------------------------------<br>/*Table :品名表Commodity_Table*/<br>C_IDSTR C_Name <br>00001 A品<br>00002 B品<br>-------------------------------------------<br>/*Table :发出表 SendCoupons_Table*/<br>C_ID C_TypeID S_SendD S_FaceValue S_EndD C_IDSTR<br>021010 10 2008-05-01 30 2008-05-20 00001<br>021011 10 2008-05-01 30 2008-05-20 00001<br>021010 11 2008-03-01 20 2008-05-24 00002<br>021011 11 2008-03-01 20 2008-05-24 00002<br>--------------------------------------------------------------------------------------------------------------------<br>/*Table :回收表 RecoveryCoupons_Table*/<br>C_ID C_TypeID R_SendD <br>021010 10 2008-05-01 <br>021011 10 2008-05-01 <br>021010 11 2008-03-01 <br>-----------------------------------------------------<br>跟据实例数据及日期条件要实现的统计结果:<br>品名 类别 面值 面值总额 发出数 回收数 未回收数(发出数-回收数) <br> A品 A类 30 60 2 2 0<br> B品 B类 20 40 2 1 1