Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.20 KB | None | 0 0
  1. --na podstawie struktyury tabeli department zalozyc typ obiektowy a dalej tabele wierszowa
  2. --utworzyc tabele z ref do objektu powoanego w pierwszym punkcie
  3. --zaladowac dane takiej strukturo do tabeli department przez instacje obiektu potem zaladowac nade do tabeli employees
  4.  
  5. --create table emp as select * from SCOTT.emp;
  6.  
  7. --CREATE TYPE t_department AS OBJECT (
  8. --deptno NUMBER(2,0),
  9. --dname VARCHAR2(14),
  10. --LOC VARCHAR2(13)
  11. --);
  12.  
  13. --create table depts of t_department;
  14.  
  15. --CREATE TABLE emps (
  16. --empno NUMBER(4,0),
  17. --ename VARCHAR2(10),
  18. --job VARCHAR2(9),
  19. --mgr NUMBER(2,0),
  20. --hiredate date,
  21. --SAL NUMBER(7,2),
  22. --COMM NUMBER(7,2),
  23. --dept REF t_department not null
  24. --);
  25.  
  26.  
  27. --insert into depts
  28. --values (1, 'dept1', 'gdzies' );
  29. --
  30. --insert into depts
  31. --values (2, 'dept2', 'gdzies2' );
  32.  
  33. --insert into emps
  34. --values (1, 'name1', 'somejob', '12', Date.today(), 123.20, 1.20, );
  35. --select * from emp;
  36. --DECLARE
  37. -- dept REF t_department;
  38. --BEGIN
  39. -- insert into depts dd
  40. -- values (3, 'dept1', 'gdzies' )
  41. -- RETURNING REF(dd) INTO dept;
  42. -- INSERT INTO emps VALUES (1, 'name1', 'somejob', '12', SYSDATE , 123.20, 1.20,dept);
  43. -- INSERT INTO emps VALUES (2, 'name2', 'somejob', '13', SYSDATE, 123.20, 1.20,dept);
  44. --END;
  45. --
  46. --select e.ename, e.dept.dname from emps e;
  47.  
  48. --1.
  49. --odwzorować na podstawie struktury bazy biblioteka za pomoca referencji relacje zachadzace miedzy tabelami
  50. --autorzy, kategorie, wydawcy, szafki po stronie tabeli publickacje
  51. --tabela kolumnowa
  52.  
  53.  
  54. --CREATE TYPE t_szafka AS OBJECT (
  55. --idszafki NUMBER(2,0),
  56. --polozenie VARCHAR2(14)
  57. --);
  58. --
  59. --create or replace TYPE t_wydawca AS OBJECT (
  60. --idwydawcy NUMBER(2,0),
  61. --nazwawydawcy VARCHAR2(14)
  62. --);
  63. --
  64. --CREATE TABLE publikacje (
  65. --idpublickacji NUMBER(4,0),
  66. --autor REF t_autorzy not null,
  67. --kategoria REF t_kategorie not null,
  68. --tytul VARCHAR2(9),
  69. --wydawca REF t_wydawca not null,
  70. --miejsce VARCHAR2(15),
  71. --szafka REF t_szafka not null,
  72. --slowa_kluczowe VARCHAR2(255)
  73. --);
  74.  
  75. --2.odwzorować na podstawie struktury bazy northwind za pomoca 2 referencji relacje zachadzace miedzy tabelami
  76. --kategories, suppplies, products
  77. --tabela wierszowa
  78.  
  79.  
  80. --create table supplies as select * from NORTHWIND.suppliers;
  81.  
  82. --1. odwzorowac na podstwioe bazy biblioteka za pomoca referencji relacje zachodzace miedzy tabeli autorzy kategorie wydawcy szafki po stronie tabli publikacje, tabela ma byc kolumnowa
  83. --2. odwzorowac relacje na podstawie bazy northwind za pomoca dwoch referencji relacja zachodzace miedzy tabelami categories supplier products kazdy ma byc typem obkietowym i przechowywac obiekty
  84. --3. jak w zad 2 ale zastosowac tabele wierszowa ktorej sklaadowaniem obiektu ma byc w inny sposob niz w zadaniu 1 i 2
  85.  
  86. --create or replace type t_autor as object (
  87. -- idautor number(3),
  88. -- nazwisko VARCHAR2(30),
  89. -- imie VARCHAR2(30),
  90. -- uwagi VARCHAR2(30)
  91. --);
  92. --
  93. --create or replace type t_kategorie as object (
  94. -- idkat number(3),
  95. -- kategoria VARCHAR2(30)
  96. --);
  97. --
  98. --create or replace type t_wydawca as object (
  99. -- idwydawcy number(3),
  100. -- nazwa VARCHAR2(30)
  101. --);
  102. --
  103. --create or replace type t_szafka as object (
  104. -- idszafka number(3),
  105. -- polozenie VARCHAR2(30)
  106. --);
  107. --
  108. --
  109. --create table autorzy of t_autor;
  110. --create table kategorie of t_kategorie;
  111. --create table wydawcy of t_wydawca;
  112. --create table szafki of t_szafka;
  113. --
  114. --create table pubs(
  115. -- idksiazki number(4),
  116. -- autor ref t_autor NOT NULL,
  117. -- kategoria ref t_kategorie NOT NULL,
  118. -- tytul VARCHAR2(30),
  119. -- wydawca ref t_wydawca NOT NULL,
  120. -- rok number(4),
  121. -- miejsce VARCHAR2(30),
  122. -- szafka ref t_szafka NOT NULL,
  123. -- slowa_klucz VARCHAR2(30)
  124. --)
  125. --
  126. --select * from autorzy;
  127. --
  128. --INSERT INTO autorzy VALUES (1,'Kowalski','Jak',NULL);
  129. --INSERT INTO autorzy VALUES (2,'Nowak','Iga',NULL);
  130. --INSERT INTO autorzy VALUES (3,'Cos','Agata',NULL);
  131. --commit;
  132.  
  133.  
  134. --------------------------------------NESTED TABLE RELATIONS--------------------------------------------------------
  135. --create type emp_typeNT AS Object
  136. --(ampno number(4),
  137. --ename varchar2(10)
  138. --);
  139. --
  140. --create type emp_table as table of emp_typeNT;
  141.  
  142. --create table deptNT
  143. --(
  144. --deptno number(2),
  145. --dname varchar2(14),
  146. --emps emp_table)
  147. --Nested table emps store as store_dept_empsNT;
  148.  
  149.  
  150. --insert into deptNT Values
  151. --(1, 'janitorial',
  152. -- emp_table(
  153. -- emp_typeNT(1, 'Lukasz'),
  154. -- emp_typeNT(2, 'Marcin')
  155. -- )
  156. --);
  157.  
  158.  
  159. --insert into deptNT Values
  160. --(2, 'STATISTICS',
  161. -- emp_table(
  162. -- emp_typeNT(3, 'LALA'),
  163. -- emp_typeNT(4, 'PO')
  164. -- )
  165. --);
  166.  
  167. --commit;
  168.  
  169. --Select ampno, ename From the
  170. -- (select emps from deptNT Where dname = 'janitorial');
  171.  
  172. --SELECT e.ampno, e.ename
  173. --From deptNT d,
  174. --TABLE(emps) e
  175. --WHERE d.dname = 'janitorial'
  176.  
  177. -----------------------------------PROJEKT------------------------------------------
  178.  
  179. ---referencje
  180.  
  181.  
  182. --CREATE TYPE t_trainingDate AS OBJECT (
  183. --name VARCHAR2(14),
  184. --startDate DATE,
  185. --endDate DATE
  186. --);
  187. --create table trainingDate of t_trainingDate;
  188.  
  189. --CREATE TYPE t_contact AS OBJECT (
  190. --firstName VARCHAR2(20),
  191. --lastName VARCHAR2(20),
  192. --contactType VARCHAR2(20),
  193. --email VARCHAR2(20),
  194. --phone VARCHAR2(20),
  195. --pesel VARCHAR2(20),
  196. --training training,
  197. --trainingToContact trainingToContact
  198. --)
  199. --Nested table trainingToContact store as store_trainingToContact,
  200. --Nested table training store as store_training;
  201.  
  202. --
  203. CREATE TYPE t_training AS OBJECT (
  204. name VARCHAR2(14),
  205. price NUMBER(6,2),
  206. lastName VARCHAR2(20),
  207. refunded BOOLEAN,
  208. trainingDate trainingDate
  209. )
  210. Nested table trainingDate store as store_trainingDate;
  211.  
  212. --CREATE TYPE t_user AS OBJECT (
  213. --firstName VARCHAR2(20),
  214. --lastName VARCHAR2(20),
  215. --login VARCHAR2(20),
  216. --pass VARCHAR2(20),
  217. --email VARCHAR2(40),
  218. --trainig trainingT
  219. --)
  220. --Nested table trainig store as store_training;
  221.  
  222.  
  223. --CREATE TYPE t_gym AS OBJECT (
  224. --name VARCHAR2(20),
  225. --city VARCHAR2(20),
  226. --street VARCHAR2(20),
  227. --building VARCHAR2(20),
  228. --phoneNumber VARCHAR2(20),
  229. --postalCode VARCHAR2(20),
  230. --email VARCHAR2(40),
  231. --gymCapacity number(3),
  232. --training trainingT
  233. --)
  234. --Nested table trainig store as store_training;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement