Advertisement
alexarcan

dbd_lab5 export

Oct 31st, 2016
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.95 KB | None | 0 0
  1. --------------------------------------------------------
  2. -- File created - Monday-October-31-2016
  3. --------------------------------------------------------
  4. --------------------------------------------------------
  5. -- DDL for Table BINDPRODUCTSPROPERTIES
  6. --------------------------------------------------------
  7.  
  8. CREATE TABLE "BINDPRODUCTSPROPERTIES"
  9. ( "PRODUCTID" NUMBER(4,0),
  10. "PROPERTYID" NUMBER(4,0)
  11. ) ;
  12. --------------------------------------------------------
  13. -- DDL for Table CATEGORIES
  14. --------------------------------------------------------
  15.  
  16. CREATE TABLE "CATEGORIES"
  17. ( "CATEGORYID" NUMBER(4,0),
  18. "CATEGORYNAME" VARCHAR2(40 BYTE),
  19. "OTHERCATID" NUMBER(4,0)
  20. ) ;
  21. --------------------------------------------------------
  22. -- DDL for Table CLIENTS
  23. --------------------------------------------------------
  24.  
  25. CREATE TABLE "CLIENTS"
  26. ( "CLIENTID" NUMBER(4,0),
  27. "CLIENTNAME" VARCHAR2(40 BYTE),
  28. "CLIENTADDRESS" VARCHAR2(200 BYTE)
  29. ) ;
  30. --------------------------------------------------------
  31. -- DDL for Table ORDEREDITEMS
  32. --------------------------------------------------------
  33.  
  34. CREATE TABLE "ORDEREDITEMS"
  35. ( "ORDERID" NUMBER(4,0),
  36. "PRODUCTID" NUMBER(4,0),
  37. "QUANTITY" NUMBER(4,0)
  38. ) ;
  39. --------------------------------------------------------
  40. -- DDL for Table ORDERS
  41. --------------------------------------------------------
  42.  
  43. CREATE TABLE "ORDERS"
  44. ( "ORDERID" NUMBER(4,0),
  45. "CLIENTID" NUMBER(4,0),
  46. "REQUESTDATE" DATE,
  47. "CONFIRMATIONDATE" DATE
  48. ) ;
  49. --------------------------------------------------------
  50. -- DDL for Table PRICES
  51. --------------------------------------------------------
  52.  
  53. CREATE TABLE "PRICES"
  54. ( "PRODUCTID" NUMBER(4,0),
  55. "STARTDATE" DATE,
  56. "ENDDATE" DATE,
  57. "PRICE" NUMBER(6,2)
  58. ) ;
  59. --------------------------------------------------------
  60. -- DDL for Table PRODUCTS
  61. --------------------------------------------------------
  62.  
  63. CREATE TABLE "PRODUCTS"
  64. ( "PRODUCTID" NUMBER(4,0),
  65. "PRODUCTNAME" VARCHAR2(40 BYTE),
  66. "CATEGORYID" NUMBER(4,0)
  67. ) ;
  68. --------------------------------------------------------
  69. -- DDL for Table PROPERTIES
  70. --------------------------------------------------------
  71.  
  72. CREATE TABLE "PROPERTIES"
  73. ( "PROPERTYID" NUMBER(4,0),
  74. "PROPERTYNAME" VARCHAR2(40 BYTE),
  75. "PROPERTYVALUE" VARCHAR2(40 BYTE)
  76. ) ;
  77. REM INSERTING into BINDPRODUCTSPROPERTIES
  78. Insert into BINDPRODUCTSPROPERTIES (PRODUCTID,PROPERTYID) values (0,0);
  79. Insert into BINDPRODUCTSPROPERTIES (PRODUCTID,PROPERTYID) values (1,1);
  80. Insert into BINDPRODUCTSPROPERTIES (PRODUCTID,PROPERTYID) values (2,2);
  81. Insert into BINDPRODUCTSPROPERTIES (PRODUCTID,PROPERTYID) values (3,3);
  82. Insert into BINDPRODUCTSPROPERTIES (PRODUCTID,PROPERTYID) values (4,0);
  83. REM INSERTING into CATEGORIES
  84. Insert into CATEGORIES (CATEGORYID,CATEGORYNAME,OTHERCATID) values (0,'PC',null);
  85. Insert into CATEGORIES (CATEGORYID,CATEGORYNAME,OTHERCATID) values (1,'Toys',null);
  86. Insert into CATEGORIES (CATEGORYID,CATEGORYNAME,OTHERCATID) values (2,'Luxury',null);
  87. Insert into CATEGORIES (CATEGORYID,CATEGORYNAME,OTHERCATID) values (3,'Clothes',null);
  88. Insert into CATEGORIES (CATEGORYID,CATEGORYNAME,OTHERCATID) values (4,'Monitor',1);
  89. Insert into CATEGORIES (CATEGORYID,CATEGORYNAME,OTHERCATID) values (5,'Clock',2);
  90. Insert into CATEGORIES (CATEGORYID,CATEGORYNAME,OTHERCATID) values (6,'Clock',3);
  91. Insert into CATEGORIES (CATEGORYID,CATEGORYNAME,OTHERCATID) values (7,'Desk',0);
  92. Insert into CATEGORIES (CATEGORYID,CATEGORYNAME,OTHERCATID) values (8,'Cables',0);
  93. Insert into CATEGORIES (CATEGORYID,CATEGORYNAME,OTHERCATID) values (9,'Routers',0);
  94. Insert into CATEGORIES (CATEGORYID,CATEGORYNAME,OTHERCATID) values (10,'Laptops',0);
  95. REM INSERTING into CLIENTS
  96. Insert into CLIENTS (CLIENTID,CLIENTNAME,CLIENTADDRESS) values (0,'Giovanni Giordo','Timisoara');
  97. Insert into CLIENTS (CLIENTID,CLIENTNAME,CLIENTADDRESS) values (1,'Eric Thomas','Arad');
  98. Insert into CLIENTS (CLIENTID,CLIENTNAME,CLIENTADDRESS) values (2,'Catalin Popescu','Timisoara');
  99. Insert into CLIENTS (CLIENTID,CLIENTNAME,CLIENTADDRESS) values (3,'Maria Floreasca','Bucuresti');
  100. REM INSERTING into ORDEREDITEMS
  101. Insert into ORDEREDITEMS (ORDERID,PRODUCTID,QUANTITY) values (0,0,3);
  102. REM INSERTING into ORDERS
  103. Insert into ORDERS (ORDERID,CLIENTID,REQUESTDATE,CONFIRMATIONDATE) values (0,0,to_date('15-NOV-16 00:00:00','DD-MON-RR HH24:MI:SS'),to_date('26-NOV-16 00:00:00','DD-MON-RR HH24:MI:SS'));
  104. REM INSERTING into PRICES
  105. Insert into PRICES (PRODUCTID,STARTDATE,ENDDATE,PRICE) values (0,to_date('15-NOV-16 00:00:00','DD-MON-RR HH24:MI:SS'),to_date('26-NOV-16 00:00:00','DD-MON-RR HH24:MI:SS'),114);
  106. REM INSERTING into PRODUCTS
  107. Insert into PRODUCTS (PRODUCTID,PRODUCTNAME,CATEGORYID) values (0,'laptop',0);
  108. Insert into PRODUCTS (PRODUCTID,PRODUCTNAME,CATEGORYID) values (1,'Teddy Bear',1);
  109. Insert into PRODUCTS (PRODUCTID,PRODUCTNAME,CATEGORYID) values (2,'Watch',2);
  110. Insert into PRODUCTS (PRODUCTID,PRODUCTNAME,CATEGORYID) values (3,'Gloves',3);
  111. Insert into PRODUCTS (PRODUCTID,PRODUCTNAME,CATEGORYID) values (4,'Monitor',0);
  112. Insert into PRODUCTS (PRODUCTID,PRODUCTNAME,CATEGORYID) values (5,'Clock',5);
  113. Insert into PRODUCTS (PRODUCTID,PRODUCTNAME,CATEGORYID) values (6,'Clock',0);
  114. Insert into PRODUCTS (PRODUCTID,PRODUCTNAME,CATEGORYID) values (7,'Mouse',0);
  115. Insert into PRODUCTS (PRODUCTID,PRODUCTNAME,CATEGORYID) values (8,'usedlaptop',10);
  116. REM INSERTING into PROPERTIES
  117. Insert into PROPERTIES (PROPERTYID,PROPERTYNAME,PROPERTYVALUE) values (0,'Color','Black');
  118. Insert into PROPERTIES (PROPERTYID,PROPERTYNAME,PROPERTYVALUE) values (1,'Color','Gold');
  119. Insert into PROPERTIES (PROPERTYID,PROPERTYNAME,PROPERTYVALUE) values (2,'Brand','Calvin Klein');
  120. Insert into PROPERTIES (PROPERTYID,PROPERTYNAME,PROPERTYVALUE) values (3,'Material','Wool');
  121. --------------------------------------------------------
  122. -- DDL for Index PK_CLIENT
  123. --------------------------------------------------------
  124.  
  125. CREATE UNIQUE INDEX "PK_CLIENT" ON "CLIENTS" ("CLIENTID")
  126. ;
  127. --------------------------------------------------------
  128. -- DDL for Index PK_PROPERTY
  129. --------------------------------------------------------
  130.  
  131. CREATE UNIQUE INDEX "PK_PROPERTY" ON "PROPERTIES" ("PROPERTYID")
  132. ;
  133. --------------------------------------------------------
  134. -- DDL for Index PK_CAT
  135. --------------------------------------------------------
  136.  
  137. CREATE UNIQUE INDEX "PK_CAT" ON "CATEGORIES" ("CATEGORYID")
  138. ;
  139. --------------------------------------------------------
  140. -- DDL for Index PK_PRODUCT
  141. --------------------------------------------------------
  142.  
  143. CREATE UNIQUE INDEX "PK_PRODUCT" ON "PRODUCTS" ("PRODUCTID")
  144. ;
  145. --------------------------------------------------------
  146. -- DDL for Index PK_ORDER
  147. --------------------------------------------------------
  148.  
  149. CREATE UNIQUE INDEX "PK_ORDER" ON "ORDERS" ("ORDERID")
  150. ;
  151. --------------------------------------------------------
  152. -- Constraints for Table PRODUCTS
  153. --------------------------------------------------------
  154.  
  155. ALTER TABLE "PRODUCTS" ADD CONSTRAINT "PK_PRODUCT" PRIMARY KEY ("PRODUCTID") ENABLE;
  156. --------------------------------------------------------
  157. -- Constraints for Table CATEGORIES
  158. --------------------------------------------------------
  159.  
  160. ALTER TABLE "CATEGORIES" ADD CONSTRAINT "PK_CAT" PRIMARY KEY ("CATEGORYID") ENABLE;
  161. --------------------------------------------------------
  162. -- Constraints for Table PROPERTIES
  163. --------------------------------------------------------
  164.  
  165. ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTY" PRIMARY KEY ("PROPERTYID") ENABLE;
  166. --------------------------------------------------------
  167. -- Constraints for Table CLIENTS
  168. --------------------------------------------------------
  169.  
  170. ALTER TABLE "CLIENTS" ADD CONSTRAINT "PK_CLIENT" PRIMARY KEY ("CLIENTID") ENABLE;
  171. --------------------------------------------------------
  172. -- Constraints for Table ORDERS
  173. --------------------------------------------------------
  174.  
  175. ALTER TABLE "ORDERS" ADD CONSTRAINT "PK_ORDER" PRIMARY KEY ("ORDERID") ENABLE;
  176. --------------------------------------------------------
  177. -- Ref Constraints for Table BINDPRODUCTSPROPERTIES
  178. --------------------------------------------------------
  179.  
  180. ALTER TABLE "BINDPRODUCTSPROPERTIES" ADD CONSTRAINT "FK_PRODUCT" FOREIGN KEY ("PRODUCTID")
  181. REFERENCES "PRODUCTS" ("PRODUCTID") ENABLE;
  182.  
  183. ALTER TABLE "BINDPRODUCTSPROPERTIES" ADD CONSTRAINT "FK_PROPERTY" FOREIGN KEY ("PROPERTYID")
  184. REFERENCES "PROPERTIES" ("PROPERTYID") ENABLE;
  185. --------------------------------------------------------
  186. -- Ref Constraints for Table CATEGORIES
  187. --------------------------------------------------------
  188.  
  189. ALTER TABLE "CATEGORIES" ADD CONSTRAINT "FK_CAT" FOREIGN KEY ("OTHERCATID")
  190. REFERENCES "CATEGORIES" ("CATEGORYID") ENABLE;
  191. --------------------------------------------------------
  192. -- Ref Constraints for Table ORDEREDITEMS
  193. --------------------------------------------------------
  194.  
  195. ALTER TABLE "ORDEREDITEMS" ADD CONSTRAINT "FK_ORDER" FOREIGN KEY ("ORDERID")
  196. REFERENCES "ORDERS" ("ORDERID") ENABLE;
  197.  
  198. ALTER TABLE "ORDEREDITEMS" ADD CONSTRAINT "FK_ORDERED_ITEM" FOREIGN KEY ("PRODUCTID")
  199. REFERENCES "PRODUCTS" ("PRODUCTID") ENABLE;
  200. --------------------------------------------------------
  201. -- Ref Constraints for Table ORDERS
  202. --------------------------------------------------------
  203.  
  204. ALTER TABLE "ORDERS" ADD CONSTRAINT "FK_CLIENT" FOREIGN KEY ("CLIENTID")
  205. REFERENCES "CLIENTS" ("CLIENTID") ENABLE;
  206. --------------------------------------------------------
  207. -- Ref Constraints for Table PRICES
  208. --------------------------------------------------------
  209.  
  210. ALTER TABLE "PRICES" ADD CONSTRAINT "FK_PRICE_PRODUCT" FOREIGN KEY ("PRODUCTID")
  211. REFERENCES "PRODUCTS" ("PRODUCTID") ENABLE;
  212. --------------------------------------------------------
  213. -- Ref Constraints for Table PRODUCTS
  214. --------------------------------------------------------
  215.  
  216. ALTER TABLE "PRODUCTS" ADD CONSTRAINT "FK_CATEGORY" FOREIGN KEY ("CATEGORYID")
  217. REFERENCES "CATEGORIES" ("CATEGORYID") ENABLE;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement