Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --na podstawie struktyury tabeli department zalozyc typ obiektowy a dalej tabele wierszowa
- --utworzyc tabele z ref do objektu powoanego w pierwszym punkcie
- --zaladowac dane takiej strukturo do tabeli department przez instacje obiektu potem zaladowac nade do tabeli employees
- --create table emp as select * from SCOTT.emp;
- --CREATE TYPE t_department AS OBJECT (
- --deptno NUMBER(2,0),
- --dname VARCHAR2(14),
- --LOC VARCHAR2(13)
- --);
- --create table depts of t_department;
- --CREATE TABLE emps (
- --empno NUMBER(4,0),
- --ename VARCHAR2(10),
- --job VARCHAR2(9),
- --mgr NUMBER(2,0),
- --hiredate date,
- --SAL NUMBER(7,2),
- --COMM NUMBER(7,2),
- --dept REF t_department not null
- --);
- --insert into depts
- --values (1, 'dept1', 'gdzies' );
- --
- --insert into depts
- --values (2, 'dept2', 'gdzies2' );
- --insert into emps
- --values (1, 'name1', 'somejob', '12', Date.today(), 123.20, 1.20, );
- --select * from emp;
- --DECLARE
- -- dept REF t_department;
- --BEGIN
- -- insert into depts dd
- -- values (3, 'dept1', 'gdzies' )
- -- RETURNING REF(dd) INTO dept;
- -- INSERT INTO emps VALUES (1, 'name1', 'somejob', '12', SYSDATE , 123.20, 1.20,dept);
- -- INSERT INTO emps VALUES (2, 'name2', 'somejob', '13', SYSDATE, 123.20, 1.20,dept);
- --END;
- --
- --select e.ename, e.dept.dname from emps e;
- --1.
- --odwzorować na podstawie struktury bazy biblioteka za pomoca referencji relacje zachadzace miedzy tabelami
- --autorzy, kategorie, wydawcy, szafki po stronie tabeli publickacje
- --tabela kolumnowa
- --CREATE TYPE t_szafka AS OBJECT (
- --idszafki NUMBER(2,0),
- --polozenie VARCHAR2(14)
- --);
- --
- --create or replace TYPE t_wydawca AS OBJECT (
- --idwydawcy NUMBER(2,0),
- --nazwawydawcy VARCHAR2(14)
- --);
- --
- --CREATE TABLE publikacje (
- --idpublickacji NUMBER(4,0),
- --autor REF t_autorzy not null,
- --kategoria REF t_kategorie not null,
- --tytul VARCHAR2(9),
- --wydawca REF t_wydawca not null,
- --miejsce VARCHAR2(15),
- --szafka REF t_szafka not null,
- --slowa_kluczowe VARCHAR2(255)
- --);
- --2.odwzorować na podstawie struktury bazy northwind za pomoca 2 referencji relacje zachadzace miedzy tabelami
- --kategories, suppplies, products
- --tabela wierszowa
- --create table supplies as select * from NORTHWIND.suppliers;
- --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
- --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
- --3. jak w zad 2 ale zastosowac tabele wierszowa ktorej sklaadowaniem obiektu ma byc w inny sposob niz w zadaniu 1 i 2
- --create or replace type t_autor as object (
- -- idautor number(3),
- -- nazwisko VARCHAR2(30),
- -- imie VARCHAR2(30),
- -- uwagi VARCHAR2(30)
- --);
- --
- --create or replace type t_kategorie as object (
- -- idkat number(3),
- -- kategoria VARCHAR2(30)
- --);
- --
- --create or replace type t_wydawca as object (
- -- idwydawcy number(3),
- -- nazwa VARCHAR2(30)
- --);
- --
- --create or replace type t_szafka as object (
- -- idszafka number(3),
- -- polozenie VARCHAR2(30)
- --);
- --
- --
- --create table autorzy of t_autor;
- --create table kategorie of t_kategorie;
- --create table wydawcy of t_wydawca;
- --create table szafki of t_szafka;
- --
- --create table pubs(
- -- idksiazki number(4),
- -- autor ref t_autor NOT NULL,
- -- kategoria ref t_kategorie NOT NULL,
- -- tytul VARCHAR2(30),
- -- wydawca ref t_wydawca NOT NULL,
- -- rok number(4),
- -- miejsce VARCHAR2(30),
- -- szafka ref t_szafka NOT NULL,
- -- slowa_klucz VARCHAR2(30)
- --)
- --
- --select * from autorzy;
- --
- --INSERT INTO autorzy VALUES (1,'Kowalski','Jak',NULL);
- --INSERT INTO autorzy VALUES (2,'Nowak','Iga',NULL);
- --INSERT INTO autorzy VALUES (3,'Cos','Agata',NULL);
- --commit;
- --------------------------------------NESTED TABLE RELATIONS--------------------------------------------------------
- --create type emp_typeNT AS Object
- --(ampno number(4),
- --ename varchar2(10)
- --);
- --
- --create type emp_table as table of emp_typeNT;
- --create table deptNT
- --(
- --deptno number(2),
- --dname varchar2(14),
- --emps emp_table)
- --Nested table emps store as store_dept_empsNT;
- --insert into deptNT Values
- --(1, 'janitorial',
- -- emp_table(
- -- emp_typeNT(1, 'Lukasz'),
- -- emp_typeNT(2, 'Marcin')
- -- )
- --);
- --insert into deptNT Values
- --(2, 'STATISTICS',
- -- emp_table(
- -- emp_typeNT(3, 'LALA'),
- -- emp_typeNT(4, 'PO')
- -- )
- --);
- --commit;
- --Select ampno, ename From the
- -- (select emps from deptNT Where dname = 'janitorial');
- --SELECT e.ampno, e.ename
- --From deptNT d,
- --TABLE(emps) e
- --WHERE d.dname = 'janitorial'
- -----------------------------------PROJEKT------------------------------------------
- ---referencje
- --CREATE TYPE t_trainingDate AS OBJECT (
- --name VARCHAR2(14),
- --startDate DATE,
- --endDate DATE
- --);
- --create table trainingDate of t_trainingDate;
- --CREATE TYPE t_contact AS OBJECT (
- --firstName VARCHAR2(20),
- --lastName VARCHAR2(20),
- --contactType VARCHAR2(20),
- --email VARCHAR2(20),
- --phone VARCHAR2(20),
- --pesel VARCHAR2(20),
- --training training,
- --trainingToContact trainingToContact
- --)
- --Nested table trainingToContact store as store_trainingToContact,
- --Nested table training store as store_training;
- --
- CREATE TYPE t_training AS OBJECT (
- name VARCHAR2(14),
- price NUMBER(6,2),
- lastName VARCHAR2(20),
- refunded BOOLEAN,
- trainingDate trainingDate
- )
- Nested table trainingDate store as store_trainingDate;
- --CREATE TYPE t_user AS OBJECT (
- --firstName VARCHAR2(20),
- --lastName VARCHAR2(20),
- --login VARCHAR2(20),
- --pass VARCHAR2(20),
- --email VARCHAR2(40),
- --trainig trainingT
- --)
- --Nested table trainig store as store_training;
- --CREATE TYPE t_gym AS OBJECT (
- --name VARCHAR2(20),
- --city VARCHAR2(20),
- --street VARCHAR2(20),
- --building VARCHAR2(20),
- --phoneNumber VARCHAR2(20),
- --postalCode VARCHAR2(20),
- --email VARCHAR2(40),
- --gymCapacity number(3),
- --training trainingT
- --)
- --Nested table trainig store as store_training;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement