SHARE
TWEET

Untitled

a guest Mar 20th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --USE master;
  2. --DROP DATABASE Fabryka_Sprzetu_IT;
  3. --GO
  4.  
  5. --CREATE DATABASE Fabryka_Sprzetu_IT;
  6. --GO
  7.  
  8. --USE Fabryka_Sprzetu_IT;
  9. --GO
  10.  
  11. ------------ USUŃ TABELE ------------
  12.  
  13. DROP TABLE IF EXISTS PC;
  14. DROP TABLE IF EXISTS Laptop;
  15. DROP TABLE IF EXISTS Drukarka;
  16. DROP TABLE IF EXISTS Produkt;
  17.  
  18. ------------ CREATE - UTWÓRZ TABELE I POWIĄZANIA ------------
  19.  
  20. CREATE TABLE Produkt
  21. (
  22.     producent VARCHAR(20),
  23.     model     INTEGER,
  24.     typ       VARCHAR(20)
  25. );
  26.  
  27. CREATE TABLE PC
  28. (
  29.     model    INTEGER,
  30.     szybkosc DECIMAL(10, 2),
  31.     ram      INTEGER,
  32.     dysk     INTEGER,
  33.     cena     INTEGER
  34. );
  35.  
  36. CREATE TABLE Laptop
  37. (
  38.     model    INTEGER,
  39.     szybkosc DECIMAL(10, 2),
  40.     ram      INTEGER,
  41.     dysk     INTEGER,
  42.     ekran    DECIMAL(10, 1),
  43.     cena     INTEGER
  44. );
  45.  
  46. CREATE TABLE Drukarka
  47. (
  48.     model INTEGER,
  49.     kolor BIT,
  50.     typ   VARCHAR(20),
  51.     cena  INTEGER
  52. );
  53.  
  54. GO
  55.  
  56. ------------ INSERT - WSTAW DANE ------------
  57.  
  58. INSERT INTO Produkt VALUES
  59. ('A', 1001, 'pc'      ),
  60. ('A', 1002, 'pc'      ),
  61. ('A', 1003, 'pc'      ),
  62. ('A', 2004, 'laptop'  ),
  63. ('A', 2005, 'laptop'  ),
  64. ('A', 2006, 'laptop'  ),
  65. ('B', 1004, 'pc'      ),
  66. ('B', 1005, 'pc'      ),
  67. ('B', 1006, 'pc'      ),
  68. ('B', 2007, 'laptop'  ),
  69. ('C', 1007, 'pc'      ),
  70. ('D', 1008, 'pc'      ),
  71. ('D', 1009, 'pc'      ),
  72. ('D', 1010, 'pc'      ),
  73. ('D', 3004, 'drukarka'),
  74. ('D', 3005, 'drukarka'),
  75. ('E', 1011, 'pc'      ),
  76. ('E', 1012, 'pc'      ),
  77. ('E', 1013, 'pc'      ),
  78. ('E', 2001, 'laptop'  ),
  79. ('E', 2002, 'laptop'  ),
  80. ('E', 2003, 'laptop'  ),
  81. ('E', 3001, 'drukarka'),
  82. ('E', 3002, 'drukarka'),
  83. ('E', 3003, 'drukarka'),
  84. ('F', 2008, 'laptop'  ),
  85. ('F', 2009, 'laptop'  ),
  86. ('G', 2010, 'laptop'  ),
  87. ('H', 3006, 'drukarka'),
  88. ('H', 3007, 'drukarka');
  89.  
  90. INSERT INTO PC VALUES
  91. (1001, 2.66, 1024, 250, 2114),
  92. (1002, 2.10, 512 , 250, 995 ),
  93. (1003, 1.42, 512 , 80 , 478 ),
  94. (1004, 2.80, 1024, 250, 649 ),
  95. (1005, 3.20, 512 , 250, 630 ),
  96. (1006, 3.20, 1024, 320, 1049),
  97. (1007, 2.20, 1024, 200, 510 ),
  98. (1008, 2.20, 2048, 250, 770 ),
  99. (1009, 2.00, 1024, 250, 650 ),
  100. (1010, 2.80, 2048, 300, 770 ),
  101. (1011, 1.86, 2048, 160, 959 ),
  102. (1012, 2.80, 1024, 160, 649 ),
  103. (1013, 3.06, 512 , 80 , 529 );
  104.  
  105. INSERT INTO Laptop VALUES
  106. (2001, 2.00, 2048, 240, 20.1, 3673),
  107. (2002, 1.73, 1024, 80 , 17.0, 949 ),
  108. (2003, 1.80, 512 , 60 , 15.4, 549 ),
  109. (2004, 2.00, 512 , 60 , 13.3, 1150),
  110. (2005, 2.16, 1024, 120, 17.0, 2500),
  111. (2006, 2.00, 2048, 80 , 15.4, 1700),
  112. (2007, 1.83, 1024, 120, 13.3, 1429),
  113. (2008, 1.60, 1024, 100, 15.4, 900 ),
  114. (2009, 1.60, 512 , 80 , 14.1, 680 ),
  115. (2010, 2.00, 2048, 160, 15.4, 2300);
  116.  
  117. INSERT INTO Drukarka VALUES
  118. (3001, 'true' , 'atramentowa', 99 ),
  119. (3002, 'false', 'laserowa'   , 239),
  120. (3003, 'true' , 'laserowa'   , 899),
  121. (3004, 'true' , 'atramentowa', 120),
  122. (3005, 'false', 'laserowa'   , 120),
  123. (3006, 'true' , 'atramentowa', 100),
  124. (3007, 'true' , 'laserowa'   , 200);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top