Advertisement
Guest User

Untitled

a guest
May 23rd, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.35 KB | None | 0 0
  1. drop table zipcode cascade constraints;
  2. create table zipcode(address varchar(25) not null,
  3. code varchar(8) not null,
  4. primary key(code));
  5.  
  6. drop table gym cascade constraints;
  7. create table gym(
  8. id number(3) not null unique,
  9. code varchar(8) not null,
  10. primary key (id, code),
  11. foreign key (code) references zipcode(code) ON DELETE CASCADE);
  12.  
  13. drop table people cascade constraints;
  14. create table people(nif number(9) not null,
  15. naame varchar(35) not null,
  16. date_birth date not null,
  17. sex char(1) not null CHECK (sex IN ( 'F' , 'M' )),
  18. code varchar(8),
  19. email varchar(35) not null,
  20. iban number(21) not null,
  21. id number(3) not null,
  22. password number(4) not null,
  23. primary key (nif),
  24. foreign key (id) references gym(id) ON DELETE CASCADE);
  25.  
  26. drop table staff cascade constraints;
  27. create table staff( staff_nif number(9) not null references people(nif),
  28. primary key (staff_nif));
  29.  
  30. drop table manager cascade constraints;
  31. create table manager( manager_nif number(9) not null references staff(staff_nif),
  32. primary key (manager_nif));
  33.  
  34. drop table p_trainer cascade constraints;
  35. create table p_trainer( ptrainer_nif number(9) not null references staff(staff_nif),
  36. primary key (ptrainer_nif));
  37.  
  38. drop table membership cascade constraints;
  39. create table membership(m_id number(3) not null,
  40. price number(3) not null,
  41. description varchar(35) not null,
  42. manager_nif number(9) not null,
  43. primary key (m_id),
  44. foreign key (manager_nif) references manager(manager_nif) ON DELETE CASCADE);
  45.  
  46. drop table payment_type cascade constraints;
  47. create table payment_type(code_paym number(3) not null,
  48. description varchar(35) not null,
  49. primary key (code_paym));
  50.  
  51. drop table customers cascade constraints;
  52. create table customers( customer_nif number(9) not null references people(nif),
  53. date_joined date not null,
  54. expiration_date date not null,
  55. code_payment number(3) not null,
  56. m_id number(3) not null,
  57. primary key (customer_nif),
  58. foreign key (code_payment) references payment_type(code_paym) ON DELETE CASCADE,
  59. foreign key (m_id) references membership(m_id) ON DELETE CASCADE);
  60.  
  61.  
  62. drop table sign_up cascade constraints;
  63. create table sign_up( class_id number(3) not null,
  64. customer_nif number(9) not null,
  65. primary key (customer_nif, class_id),
  66. foreign key (customer_nif) references customers(customer_nif) ON DELETE CASCADE,
  67. foreign key (class_id) references classs(class_id) ON DELETE CASCADE);
  68.  
  69. drop table class_type cascade constraints;
  70. create table class_type(c_type number(3) not null,
  71. description varchar(35) not null,
  72. primary key (c_type));
  73.  
  74. drop table classs cascade constraints;
  75. create table classs(class_id number(3) not null,
  76. c_type number(3) not null,
  77. ptrainer_nif number(9) not null,
  78. primary key (class_id),
  79. foreign key (c_type) references class_type(c_type) ON DELETE CASCADE,
  80. foreign key (ptrainer_nif) references p_trainer(ptrainer_nif) ON DELETE CASCADE);
  81.  
  82.  
  83. drop table attendance cascade constraints;
  84. create table attendance(customer_nif number(9) not null,
  85. class_id number(3) not null,
  86. datee date not null,
  87. primary key (customer_nif, class_id, datee),
  88. foreign key (customer_nif) references customers(customer_nif) ON DELETE CASCADE,
  89. foreign key (class_id) references classs(class_id) ON DELETE CASCADE);
  90.  
  91. drop table timetable cascade constraints;
  92. create table timetable( daay number(1) not null CHECK ( daay>=2 and daay<=8),
  93. hoour number(2) not null CHECK ( hoour>=0 and hoour<24),
  94. miin number(2) not null CHECK ( miin>=0 and miin<=60 ),
  95. primary key (daay, hoour, miin));
  96.  
  97. drop table tiime cascade constraints;
  98. create table tiime( daay number(1) not null,
  99. hoour number(2) not null,
  100. miin number(2) not null,
  101. class_id number(3) not null,
  102. room number(3) not null,
  103. primary key (room, daay, hoour, miin),
  104. foreign key (class_id) references classs(class_id) ON DELETE CASCADE,
  105. foreign key (room) references rooms(id) ON DELETE CASCADE,
  106. foreign key (daay, hoour, miin) references timetable(daay, hoour, miin) ON DELETE CASCADE);
  107.  
  108. drop table equipment cascade constraints;
  109. create table equipment(eq_number number (3) not null,
  110. description varchar(35) not null,
  111. capacity number(3) not null,
  112. primary key (eq_number));
  113.  
  114.  
  115. drop table rooms cascade constraints;
  116. create table rooms( capacity number(2) not null,
  117. id number(3) not null,
  118. idgym number(3) not null,
  119. primary key (id),
  120. foreign key (idgym) references gym(id) ON DELETE CASCADE);
  121.  
  122. drop table rooms_equip cascade constraints;
  123. create table rooms_equip( room number(3) not null,
  124. equip number(3) not null,
  125. foreign key (room) references rooms(id) ON DELETE CASCADE,
  126. foreign key (equip) references equipment(eq_number) ON DELETE CASCADE);
  127.  
  128. drop view Vcustomers;
  129. create view Vcustomers as
  130. select people.nif, people.naame, people.date_birth, people.sex, people.email, customers.date_joined, people.id as Gym
  131. from people
  132. inner join customers
  133. on customers.customer_nif = people.nif
  134. order by naame;
  135.  
  136. drop view Vstaff;
  137. create view Vstaff as
  138. select people.nif, people.naame, people.date_birth, people.sex, people.email, people.id as Gym
  139. from people
  140. inner join staff
  141. on staff.staff_nif = people.nif
  142. order by naame;
  143.  
  144. drop view Vmanager;
  145. create view Vmanager as
  146. select people.nif, people.naame, people.date_birth, people.sex, people.email, people.id as Gym
  147. from people
  148. inner join manager
  149. on manager.manager_nif = people.nif
  150. order by naame;
  151.  
  152. drop view VlistClass;
  153. create view VlistClass as
  154. select classs.class_id, classs.ptrainer_nif, people.naame, count(sign_up.customer_nif) as numbCustomer
  155. from classs
  156. join sign_up on sign_up.class_id = classs.class_id
  157. join people on people.nif = classs.ptrainer_nif
  158. GROUP BY classs.class_id, classs.ptrainer_nif, people.naame;
  159.  
  160.  
  161. /***** gym *****/
  162. CREATE SEQUENCE gym_on_insert
  163. START WITH 1
  164. INCREMENT BY 1;
  165.  
  166. CREATE TRIGGER gym_on_insert
  167. BEFORE INSERT ON gym
  168. FOR EACH ROW
  169. BEGIN
  170. SELECT gym_on_insert.nextval
  171. INTO :new.id
  172. FROM dual;
  173. END;
  174. /
  175.  
  176. /***** membership *****/
  177. CREATE SEQUENCE membership_on_insert
  178. START WITH 1
  179. INCREMENT BY 1;
  180.  
  181. CREATE TRIGGER membership_on_insert
  182. BEFORE INSERT ON membership
  183. FOR EACH ROW
  184. BEGIN
  185. SELECT membership_on_insert.nextval
  186. INTO :new.m_id
  187. FROM dual;
  188. END;
  189. /
  190.  
  191.  
  192. /***** payment_type *****/
  193. CREATE SEQUENCE payment_type_on_insert
  194. START WITH 1
  195. INCREMENT BY 1;
  196.  
  197. CREATE TRIGGER payment_type_on_insert
  198. BEFORE INSERT ON payment_type
  199. FOR EACH ROW
  200. BEGIN
  201. SELECT payment_type_on_insert.nextval
  202. INTO :new.code_paym
  203. FROM dual;
  204. END;
  205. /
  206.  
  207. /***** class_type *****/
  208. CREATE SEQUENCE class_type_on_insert
  209. START WITH 1
  210. INCREMENT BY 1;
  211.  
  212. CREATE TRIGGER class_type_on_insert
  213. BEFORE INSERT ON class_type
  214. FOR EACH ROW
  215. BEGIN
  216. SELECT class_type_on_insert.nextval
  217. INTO :new.c_type
  218. FROM dual;
  219. END;
  220. /
  221.  
  222. /***** classs *****/
  223. CREATE SEQUENCE classs_on_insert
  224. START WITH 1
  225. INCREMENT BY 1;
  226.  
  227. CREATE TRIGGER classs_on_insert
  228. BEFORE INSERT ON classs
  229. FOR EACH ROW
  230. BEGIN
  231. SELECT classs_on_insert.nextval
  232. INTO :new.class_id
  233. FROM dual;
  234. END;
  235. /
  236.  
  237. /***** equipment *****/
  238. CREATE SEQUENCE equipment_on_insert
  239. START WITH 1
  240. INCREMENT BY 1;
  241.  
  242. CREATE TRIGGER equipment_on_insert
  243. BEFORE INSERT ON equipment
  244. FOR EACH ROW
  245. BEGIN
  246. SELECT equipment_on_insert.nextval
  247. INTO :new.eq_number
  248. FROM dual;
  249. END;
  250. /
  251.  
  252. /***** room *****/
  253. CREATE SEQUENCE rooms_on_insert
  254. START WITH 1
  255. INCREMENT BY 1;
  256.  
  257. CREATE TRIGGER rooms_on_insert
  258. BEFORE INSERT ON rooms
  259. FOR EACH ROW
  260. BEGIN
  261. SELECT rooms_on_insert.nextval
  262. INTO :new.id
  263. FROM dual;
  264. END;
  265. /
  266.  
  267. create or replace trigger generatePassword
  268. before insert on people
  269. for each row
  270. declare new_p number(4);
  271. begin
  272. select round(dbms_random.value(1111,9999)) into new_p from dual;
  273. :NEW.password := new_p;
  274. end;
  275. /
  276.  
  277. create or replace trigger insertGym
  278. before insert on gym
  279. for each row
  280. declare addrs varchar2(50);
  281. begin
  282. select address into addrs from zipcode where code=:NEW.code;
  283. end;
  284. /
  285.  
  286. CREATE OR REPLACE TRIGGER insertCustomers
  287. instead of insert on Vcustomers
  288. for each row
  289. begin
  290.  
  291. insert into people(nif, naame, date_birth, sex, code, email, iban,id) values(:NEW.nif, :NEW.naame, :NEW.date_birth, :NEW.sex, :NEW.code, :NEW.email, :NEW.iban, :NEW.Gym);
  292. insert into customers(customer_nif, date_joined, expiration_date, code_payment, m_id) values(:NEW.nif, :NEW.date_joined, :NEW.expiration_date, :NEW.code_payment, :NEW.m_id);
  293.  
  294. end;
  295. /
  296.  
  297. create or replace trigger deleteCustomers
  298. instead of delete on Vcustomers
  299. for each row
  300. begin
  301. delete from people where nif=:OLD.nif;
  302. delete from customers where customer_nif=:OLD.nif;
  303.  
  304. end;
  305. /
  306.  
  307. CREATE OR REPLACE TRIGGER "INSERTPT"
  308. instead of insert on VpersonalTrainer
  309. for each row
  310. begin
  311.  
  312. insert into people(nif, naame, date_birth, sex, code, email, iban, id) values(:NEW.nif, :NEW.naame, :NEW.date_birth, :NEW.sex, :NEW.code, :NEW.email, :NEW.iban, :NEW.Gym);
  313. insert into staff(staff_nif) values(:NEW.nif);
  314. insert into p_trainer(ptrainer_nif) values(:NEW.nif);
  315.  
  316. end;
  317. /
  318. create or replace trigger deletePT
  319. instead of delete on VpersonalTrainer
  320. for each row
  321. begin
  322. delete from people where nif=:OLD.nif;
  323. delete from p_trainer where ptrainer_nif=:OLD.nif;
  324.  
  325. end;
  326. /
  327. CREATE OR REPLACE TRIGGER "INSERTMANAGER"
  328. instead of insert on Vmanager
  329. for each row
  330. begin
  331.  
  332. insert into people(nif, naame, date_birth, sex, code, email, iban, id) values(:NEW.nif, :NEW.naame, :NEW.date_birth, :NEW.sex, :NEW.code, :NEW.email, :NEW.iban, :NEW.Gym);
  333. insert into staff(staff_nif) values(:NEW.nif);
  334. insert into manager(manager_nif) values(:NEW.nif);
  335.  
  336. end;
  337. /
  338. create or replace trigger deleteManager
  339. instead of delete on Vmanager
  340. for each row
  341. begin
  342. delete from people where nif=:OLD.nif;
  343. delete from manager where manager_nif=:OLD.nif;
  344.  
  345. end;
  346. /
  347.  
  348. /***ZIPCODE***/
  349. insert into zipcode (address, code) values('Alexandre Herculano', '1150-006');
  350. insert into zipcode (address, code) values('Alfragide', '2790-236');
  351. insert into zipcode (address, code) values('Almirante Reis', '1150-011');
  352. insert into zipcode (address, code) values('Arco do Cego', '1000-286');
  353. insert into zipcode (address, code) values('Elias Garcia', '1050-100');
  354.  
  355. /***GYM***/
  356. insert into gym (code) values('1150-006');
  357. insert into gym (code) values('2790-236');
  358. insert into gym (code) values('1150-011');
  359. insert into gym (code) values('1000-286');
  360. insert into gym (code) values('1050-100');
  361.  
  362.  
  363. /**PEOPLE**/
  364. insert into people (naame, date_birth, sex, code, email, iban, nif, id) values ('Tiago', '01-01-95', 'M', '1150-006', 'tiago@gmail.com', '000032123454312343231', '123456789', '1');
  365. insert into people (naame, date_birth, sex, code, email, iban, nif, id) values ('Ana', '10-01-96', 'F', '2790-236', 'ana@gmail.com', '000032123454311143231', '123456723', '2');
  366. insert into people (naame, date_birth, sex, code, email, iban, nif, id) values ('Carlos', '03-07-95', 'M', '1150-006', 'carlos@gmail.com', '000032123454312343111', '234567239', '3');
  367. insert into people (naame, date_birth, sex, code, email, iban, nif, id) values ('Duarte', '01-22-97', 'M', '2790-236', 'duarte@gmail.com', '000031113454312343231', '123423789', '3');
  368. insert into people (naame, date_birth, sex, code, email, iban, nif, id) values ('Luis', '02-15-93', 'M', '1150-011', 'luis@gmail.com', '000032123454234343231', '123450089', '2');
  369. insert into people (naame, date_birth, sex, code, email, iban, nif, id) values ('Rita', '01-04-91', 'F', '2790-236', 'rita@gmail.com', '000032123555312343231', '123456781', '4');
  370. insert into people (naame, date_birth, sex, code, email, iban, nif, id) values ('Miguel', '01-07-90', 'M', '1150-006', 'miguel@gmail.com', '000032123174312343231', '123156789', '1');
  371. insert into people (naame, date_birth, sex, code, email, iban, nif, id) values ('Joao', '01-12-90', 'M', '1150-011', 'joao@gmail.com', '000032123467512343231', '123456189', '1');
  372. insert into people (naame, date_birth, sex, code, email, iban, nif, id) values ('Luisa', '07-11-92', 'F', '1150-006', 'luisa@gmail.com', '000032123434312343231', '123422789', '3');
  373.  
  374. /**STAFF**/
  375. insert into staff(staff_nif) values ('123456789');
  376. insert into staff(staff_nif) values ('123456723');
  377. insert into staff(staff_nif) values ('234567239');
  378. insert into staff(staff_nif) values ('123423789');
  379. insert into staff(staff_nif) values ('123450089');
  380.  
  381. /**MANAGER**/
  382. insert into manager(manager_nif) values ('123456789');
  383.  
  384. /**PERSONAL TRAINER**/
  385. insert into p_trainer(ptrainer_nif) values ('123456723');
  386. insert into p_trainer(ptrainer_nif) values ('234567239');
  387. insert into p_trainer(ptrainer_nif) values ('123423789');
  388. insert into p_trainer(ptrainer_nif) values ('123450089');
  389.  
  390. /***TIME_TABLE***/
  391. insert into timetable(daay, hoour, miin) values(2, 16, 0);
  392. insert into timetable(daay, hoour, miin) values(2, 16, 15);
  393. insert into timetable(daay, hoour, miin) values(2, 16, 30);
  394. insert into timetable(daay, hoour, miin) values(2, 16, 45);
  395. insert into timetable(daay, hoour, miin) values(2, 17, 0);
  396. insert into timetable(daay, hoour, miin) values(2, 17, 15);
  397. insert into timetable(daay, hoour, miin) values(2, 17, 30);
  398. insert into timetable(daay, hoour, miin) values(2, 17, 45);
  399. insert into timetable(daay, hoour, miin) values(2, 18, 0);
  400. insert into timetable(daay, hoour, miin) values(2, 18, 15);
  401. insert into timetable(daay, hoour, miin) values(2, 18, 30);
  402. insert into timetable(daay, hoour, miin) values(2, 18, 45);
  403. insert into timetable(daay, hoour, miin) values(2, 19, 0);
  404. insert into timetable(daay, hoour, miin) values(2, 19, 15);
  405. insert into timetable(daay, hoour, miin) values(2, 19, 30);
  406. insert into timetable(daay, hoour, miin) values(2, 19, 45);
  407. insert into timetable(daay, hoour, miin) values(2, 20, 0);
  408. insert into timetable(daay, hoour, miin) values(2, 20, 15);
  409. insert into timetable(daay, hoour, miin) values(2, 20, 30);
  410. insert into timetable(daay, hoour, miin) values(2, 20, 45);
  411. insert into timetable(daay, hoour, miin) values(3, 16, 0);
  412. insert into timetable(daay, hoour, miin) values(3, 16, 15);
  413. insert into timetable(daay, hoour, miin) values(3, 16, 30);
  414. insert into timetable(daay, hoour, miin) values(3, 16, 45);
  415. insert into timetable(daay, hoour, miin) values(3, 17, 0);
  416. insert into timetable(daay, hoour, miin) values(3, 17, 15);
  417. insert into timetable(daay, hoour, miin) values(3, 17, 30);
  418. insert into timetable(daay, hoour, miin) values(3, 17, 45);
  419. insert into timetable(daay, hoour, miin) values(3, 18, 0);
  420. insert into timetable(daay, hoour, miin) values(3, 18, 15);
  421. insert into timetable(daay, hoour, miin) values(3, 18, 30);
  422. insert into timetable(daay, hoour, miin) values(3, 18, 45);
  423. insert into timetable(daay, hoour, miin) values(3, 19, 0);
  424. insert into timetable(daay, hoour, miin) values(3, 19, 15);
  425. insert into timetable(daay, hoour, miin) values(3, 19, 30);
  426. insert into timetable(daay, hoour, miin) values(3, 19, 45);
  427. insert into timetable(daay, hoour, miin) values(3, 20, 0);
  428. insert into timetable(daay, hoour, miin) values(3, 20, 15);
  429. insert into timetable(daay, hoour, miin) values(3, 20, 30);
  430. insert into timetable(daay, hoour, miin) values(3, 20, 45);
  431. insert into timetable(daay, hoour, miin) values(4, 16, 0);
  432. insert into timetable(daay, hoour, miin) values(4, 16, 15);
  433. insert into timetable(daay, hoour, miin) values(4, 16, 30);
  434. insert into timetable(daay, hoour, miin) values(4, 16, 45);
  435. insert into timetable(daay, hoour, miin) values(4, 17, 0);
  436. insert into timetable(daay, hoour, miin) values(4, 17, 15);
  437. insert into timetable(daay, hoour, miin) values(4, 17, 30);
  438. insert into timetable(daay, hoour, miin) values(4, 17, 45);
  439. insert into timetable(daay, hoour, miin) values(4, 18, 0);
  440. insert into timetable(daay, hoour, miin) values(4, 18, 15);
  441. insert into timetable(daay, hoour, miin) values(4, 18, 30);
  442. insert into timetable(daay, hoour, miin) values(4, 18, 45);
  443. insert into timetable(daay, hoour, miin) values(4, 19, 0);
  444. insert into timetable(daay, hoour, miin) values(4, 19, 15);
  445. insert into timetable(daay, hoour, miin) values(4, 19, 30);
  446. insert into timetable(daay, hoour, miin) values(4, 19, 45);
  447. insert into timetable(daay, hoour, miin) values(4, 20, 0);
  448. insert into timetable(daay, hoour, miin) values(4, 20, 15);
  449. insert into timetable(daay, hoour, miin) values(4, 20, 30);
  450. insert into timetable(daay, hoour, miin) values(4, 20, 45);
  451. insert into timetable(daay, hoour, miin) values(5, 16, 0);
  452. insert into timetable(daay, hoour, miin) values(5, 16, 15);
  453. insert into timetable(daay, hoour, miin) values(5, 16, 30);
  454. insert into timetable(daay, hoour, miin) values(5, 16, 45);
  455. insert into timetable(daay, hoour, miin) values(5, 17, 0);
  456. insert into timetable(daay, hoour, miin) values(5, 17, 15);
  457. insert into timetable(daay, hoour, miin) values(5, 17, 30);
  458. insert into timetable(daay, hoour, miin) values(5, 17, 45);
  459. insert into timetable(daay, hoour, miin) values(5, 18, 0);
  460. insert into timetable(daay, hoour, miin) values(5, 18, 15);
  461. insert into timetable(daay, hoour, miin) values(5, 18, 30);
  462. insert into timetable(daay, hoour, miin) values(5, 18, 45);
  463. insert into timetable(daay, hoour, miin) values(5, 19, 0);
  464. insert into timetable(daay, hoour, miin) values(5, 19, 15);
  465. insert into timetable(daay, hoour, miin) values(5, 19, 30);
  466. insert into timetable(daay, hoour, miin) values(5, 19, 45);
  467. insert into timetable(daay, hoour, miin) values(5, 20, 0);
  468. insert into timetable(daay, hoour, miin) values(5, 20, 15);
  469. insert into timetable(daay, hoour, miin) values(5, 20, 30);
  470. insert into timetable(daay, hoour, miin) values(5, 20, 45);
  471. insert into timetable(daay, hoour, miin) values(6, 16, 0);
  472. insert into timetable(daay, hoour, miin) values(6, 16, 15);
  473. insert into timetable(daay, hoour, miin) values(6, 16, 30);
  474. insert into timetable(daay, hoour, miin) values(6, 16, 45);
  475. insert into timetable(daay, hoour, miin) values(6, 17, 0);
  476. insert into timetable(daay, hoour, miin) values(6, 17, 15);
  477. insert into timetable(daay, hoour, miin) values(6, 17, 30);
  478. insert into timetable(daay, hoour, miin) values(6, 17, 45);
  479. insert into timetable(daay, hoour, miin) values(6, 18, 0);
  480. insert into timetable(daay, hoour, miin) values(6, 18, 15);
  481. insert into timetable(daay, hoour, miin) values(6, 18, 30);
  482. insert into timetable(daay, hoour, miin) values(6, 18, 45);
  483. insert into timetable(daay, hoour, miin) values(6, 19, 0);
  484. insert into timetable(daay, hoour, miin) values(6, 19, 15);
  485. insert into timetable(daay, hoour, miin) values(6, 19, 30);
  486. insert into timetable(daay, hoour, miin) values(6, 19, 45);
  487. insert into timetable(daay, hoour, miin) values(6, 20, 0);
  488. insert into timetable(daay, hoour, miin) values(6, 20, 15);
  489. insert into timetable(daay, hoour, miin) values(6, 20, 30);
  490. insert into timetable(daay, hoour, miin) values(6, 20, 45);
  491.  
  492.  
  493.  
  494. /***EQUIPMENT***/
  495. insert into equipment(description, capacity) values('Prensa a 45º musculação', 2);
  496. insert into equipment(description, capacity) values('Banco Supino', 5);
  497. insert into equipment(description, capacity) values('Halteres', 200);
  498. insert into equipment(description, capacity) values('Passadeira', 10);
  499. insert into equipment(description, capacity) values('Bicicleta', 75);
  500.  
  501. /**CLASSS**/
  502. insert into classs (c_type, ptrainer_nif) values ('1', '123456723');
  503. insert into classs (c_type, ptrainer_nif) values ('2', '234567239');
  504. insert into classs (c_type, ptrainer_nif) values ('3', '123423789');
  505. insert into classs (c_type, ptrainer_nif) values ('4', '123450089');
  506.  
  507. /**CUSTOMERS**/
  508. insert into customers(customer_nif, date_joined, expiration_date, code_payment, m_id) values ('123456781', '01-15-16','02-15-16', '1', '2');
  509. insert into customers(customer_nif, date_joined, expiration_date, code_payment, m_id) values ('123156789', '01-15-16','01-30-16', '2', '1');
  510. insert into customers(customer_nif, date_joined, expiration_date, code_payment, m_id) values ('123456189', '03-11-16','03-11-17', '3', '2');
  511. insert into customers(customer_nif, date_joined, expiration_date, code_payment, m_id) values ('123422789', '05-20-16','06-20-16', '2', '1');
  512.  
  513.  
  514. /***ROOMS***/
  515. insert into rooms(capacity, idgym) values('50', '1');
  516. insert into rooms(capacity, idgym) values('50', '1');
  517. insert into rooms(capacity, idgym) values('30', '4');
  518. insert into rooms(capacity, idgym) values('45', '2');
  519. insert into rooms(capacity, idgym) values('80', '2');
  520. insert into rooms(capacity, idgym) values('40', '4');
  521. insert into rooms(capacity, idgym) values('25', '4');
  522. insert into rooms(capacity, idgym) values('52', '1');
  523. insert into rooms(capacity, idgym) values('63', '3');
  524. insert into rooms(capacity, idgym) values('53', '3');
  525. insert into rooms(capacity, idgym) values('24', '3');
  526.  
  527.  
  528. /**SIGN_UP**/
  529. insert into sign_up (class_id, customer_nif) values (1, 123456781);
  530. insert into sign_up (class_id, customer_nif) values (1, 123156789);
  531. insert into sign_up (class_id, customer_nif) values (2, 123422789);
  532. insert into sign_up (class_id, customer_nif) values (1, 123456189);
  533.  
  534.  
  535. /***ROOMS***/
  536. insert into rooms(capacity, idgym) values('50', '1');
  537. insert into rooms(capacity, idgym) values('50', '1');
  538. insert into rooms(capacity, idgym) values('30', '4');
  539. insert into rooms(capacity, idgym) values('45', '2');
  540. insert into rooms(capacity, idgym) values('80', '2');
  541. insert into rooms(capacity, idgym) values('40', '4');
  542. insert into rooms(capacity, idgym) values('25', '4');
  543. insert into rooms(capacity, idgym) values('52', '1');
  544. insert into rooms(capacity, idgym) values('63', '3');
  545. insert into rooms(capacity, idgym) values('53', '3');
  546. insert into rooms(capacity, idgym) values('24', '3');
  547.  
  548. /***ROOMS_EQUIP***/
  549. insert into rooms_equip(room, equip) values(1,2);
  550. insert into rooms_equip(room, equip) values(1,2);
  551. insert into rooms_equip(room, equip) values(2,3);
  552. insert into rooms_equip(room, equip) values(3,4);
  553. insert into rooms_equip(room, equip) values(6,5);
  554. insert into rooms_equip(room, equip) values(8,1);
  555. insert into rooms_equip(room, equip) values(8,2);
  556. insert into rooms_equip(room, equip) values(8,3);
  557.  
  558. /**ATTENDANCE**/
  559. insert into attendance(customer_nif, class_id, datee) values ('123456781', '1', '12-07-16');
  560. insert into attendance(customer_nif, class_id, datee) values ('123456781', '2', '11-07-16');
  561. insert into attendance(customer_nif, class_id, datee) values ('123456781', '3', '10-07-16');
  562. insert into attendance(customer_nif, class_id, datee) values ('123456781', '4', '09-07-16');
  563.  
  564.  
  565. /***insert_TIIME***/
  566. insert into tiime (daay, hoour, miin, class_id, room) values('2', '19', '00', '1', '10');
  567. insert into tiime (daay, hoour, miin, class_id, room) values('2', '19', '30', '2', '4');
  568. insert into tiime (daay, hoour, miin, class_id, room) values('3', '19', '30', '3', '7');
  569. insert into tiime (daay, hoour, miin, class_id, room) values('4', '17', '30', '2', '8');
  570. insert into tiime (daay, hoour, miin, class_id, room) values('3', '18', '30', '4', '6');
  571. insert into tiime (daay, hoour, miin, class_id, room) values('2', '17', '15', '4', '2');
  572. insert into tiime (daay, hoour, miin, class_id, room) values('5', '19', '30', '4', '5');
  573. insert into tiime (daay, hoour, miin, class_id, room) values('6', '19', '00', '4', '3');
  574. insert into tiime (daay, hoour, miin, class_id, room) values('2', '19', '30', '2', '1');
  575.  
  576.  
  577. /**MEMBERSHIP**/
  578.  
  579. insert into membership (price, description, manager_nif) values ('15', 'Access to a gym', '123456789');
  580. insert into membership (price, description, manager_nif) values ('20', 'Access to all gyms', '123456789');
  581.  
  582.  
  583.  
  584. /**PAYMENT_TYPE**/
  585. insert into payment_type(description) values('monthly')
  586. insert into payment_type(description) values('bi-weekly');
  587. insert into payment_type(description) values('annual');
  588.  
  589. /**CLASS_TYPE**/
  590. insert into class_type(description) values('Zumba');
  591. insert into class_type(description) values('Dance Moves');
  592. insert into class_type(description) values('Pilates Moves');
  593. insert into class_type(description) values('Yoga Moves');
  594. insert into class_type(description) values('BodyAttack');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement