Advertisement
alexarcan

lab1_dbd(DONE)

Oct 3rd, 2016
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. create table Categories(
  2. CategoryID number(4),
  3. CategoryName varchar2(40),
  4. OtherCatID number(4),
  5. constraint pk_cat primary key(CategoryID),
  6. constraint fk_cat FOREIGN KEY(OtherCatID) REFERENCES Categories(CategoryID)
  7. );
  8.  
  9. create table Products(
  10. ProductID number(4),
  11. ProductName varchar2(40),
  12. CategoryID number(4),
  13. constraint pk_product primary key(ProductID),
  14. constraint fk_category foreign key(CategoryID) references Categories(CategoryID)
  15. );
  16.  
  17. create table Properties(
  18. PropertyId number(4),
  19. PropertyName varchar2(40),
  20. PropertyValue varchar2(40),
  21. constraint pk_property primary key(PropertyID)
  22. );
  23.  
  24. create table BindProductsProperties(
  25. ProductID number(4),
  26. PropertyID number(4),
  27. constraint fk_product foreign key(ProductID) references Products(ProductID),
  28. constraint fk_property foreign key(PropertyID) references Properties(PropertyID)
  29. );
  30.  
  31. create table Clients(
  32. ClientID number(4),
  33. ClientName varchar2(40),
  34. ClientAddress varchar2(200),
  35. constraint pk_client primary key(ClientID)
  36. );
  37.  
  38. create table Orders(
  39. OrderID number(4),
  40. ClientID number(4),
  41. RequestDate date,
  42. ConfirmationDate date,
  43. constraint pk_order primary key(OrderID),
  44. constraint fk_client foreign key(ClientID) references Clients(ClientID)
  45. );
  46.  
  47. create table OrderedItems(
  48. OrderID number(4),
  49. ProductID number(4),
  50. Quantity number(4),
  51. constraint fk_order foreign key(OrderID) references Orders(OrderID),
  52. constraint fk_ordered_item foreign key(ProductID) references Products(ProductID)
  53. );
  54.  
  55. create table Prices(
  56. ProductID number(4),
  57. StartDate date,
  58. EndDate date,
  59. Price number(6,2),
  60. constraint fk_price_product foreign key(ProductID) references Products(ProductID)
  61. );
  62.  
  63. insert into Categories values (0,'PC',null);
  64. insert into Categories values (1,'Toys',null);
  65. insert into Categories values (2,'Luxury',null);
  66. insert into Categories values (3,'Clothes',null);
  67.  
  68. insert into Clients values (0,'Giovanni Giordo','Timisoara');
  69. insert into Clients values (1,'Eric Thomas','Arad');
  70. insert into Clients values (2,'Catalin Popescu','Timisoara');
  71. insert into Clients values (3,'Maria Floreasca','Bucuresti');
  72.  
  73. insert into Products values (0,'Laptop',0);
  74. insert into Products values (1,'Teddy Bear',1);
  75. insert into Products values (2,'Watch',2);
  76. insert into Products values (3,'Gloves',3);
  77.  
  78. insert into Properties values (0,'Color','Black');
  79. insert into Properties values (1,'Color','Gold');
  80. insert into Properties values (2,'Brand','Calvin Klein');
  81. insert into Properties values (3,'Material','Wool');
  82.  
  83. insert into BindProductsProperties values(0,0);
  84. insert into BindProductsProperties values(1,1);
  85. insert into BindProductsProperties values(2,2);
  86. insert into BindProductsProperties values(3,3);
  87.  
  88. insert into Orders values (0,0,'15-NOV-16','26-NOV-16');
  89. insert into OrderedItems values (0,0,3);
  90. insert into Prices values (0,'15-NOV-2016','26-NOV-2016',114);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement