Az előadás letöltése folymat van. Kérjük, várjon

Az előadás letöltése folymat van. Kérjük, várjon

Szentjánosbogár Camp Applications

Hasonló előadás


Az előadások a következő témára: "Szentjánosbogár Camp Applications"— Előadás másolata:

1 Szentjánosbogár Camp Applications
„Campply” PPKE-ITK, II. year, DataBase System project spring Gábor Oltványi Consultant: Benedek Kaposi

2 Table of Contents Front Page Table of Contents Specification
Relational Schemes Entity-Relation Diagrams (outline, complete) Functional Dependencies Normalization to BCNF Creating Tables – in SQL Inserting into Tables – in SQL Selecting from Tables – in SQL Triggers In Hungarian…

3 Specification – 1 Children (Szentjanosbogar) applicate to camps this summer (CampThisYear), which are organized all over the country (TakesPlace). In these – excepts for the "Seniors’ Camp" (CampThisYear/Senior) (so that in the Children’s [aged 10-14], Adolescents’ [aged 14-16] and Juniors’ Camps [aged 16-20] (CampThisYear/ChildAdolJunior)) – inhabitants (Inhabitant) accomodate (Accomodating + GivesHome) the children. In the Senior Camp there’s only one building, where everyone sleeps (SleepIn), in rooms (RoomIn) (Room: Number, Max person). In each camp, there are groups (Grop), there are leaders in each group, excepts for the Seniors’ Camp. There are five Children’s Camps, one Adolescents’ Camp in the same week, then there is one Juniors’ Camp the next week, and later one Seniors’ Camp so. Children who applicate to Children’s Camp have to give a priority list (Priority), to indicate which camp they prefer, if the first camp they’ve marked first is full (when there are less inhabitants who can accomodate). So those who apllicate later (by ApplDate) can go to the second, third, etc. camps on their list (["logical"] IsGoingThere attribute is true, if he will go there finally). There’s also an Archive attached to the database, about the former events (Event) and about who has been where (Appeared) so far.

4 Specification – 2 (details)
An applicant can be a participant, organizer, camp preacher, camp leader, groupleader (except Senior’s Camp), and other (Status). In the children’s application form, there are the following fields: name (Name), address (AddrCity, AddrZip, AddrStreet), phone numbers (MobPhone, HomePhone), (s) ( ), place (BornPlace) and date of birth (BornDate), school class (Class), parson’s name (ParsonName), parish address (ParishAddress), parish phone number (ParishPhone), religion teacher or Szentjánosbogár Club’s leader (ReligLeader), illness (IllName), medicine (Medicine), will this medicine with be him during the camp or not (WillHaveMedicine), parent’s name (ParentName), notification (ParentNotification), how much they can pay (CanPay) in the costs of the camp (it can be more or less depending on their possibilities), and how he will arrive to the camp (GettingTo, usually: by car or from Budapest or from an other city with the others). Applicants can indicate with whom they wish to have (or have not: H_ToBeOrNot, G_ToBeOrNot) the same accomodation or group (ClaimToBeIn1Home, ClaimToBeIn1Group). From the hosters we ask the name, address, phone numbers (+ WorkPhone). And also the number of children can they accomodate (CanAccChild), and the number in the last resort (CanAccMax), what is their ideal girl-boy rate preference (GirlBoyRate), how much time it takes to get the morning meeting point from their homes (DistanceFrom), and what is the best vehicle to be used (Vehicle: on foot, by bicicle, car, bus). We store about a former event its type (EventType: "gyerektábor", "kamasztábor", "ifitábor", "szeniortábor", "ősbogártábor", "bál", "rajzás", "métabajnokság", "lelkigyakorlat", "vezetőképző", "táborelőkészítő nap", "konditábor", "játékklub", "bogármise"), its place (ExPlace), the starting (EventStarted) and the ending date (EventEnded). About the participants of these event (Appeared) we store their status (ExStatus: organizer, leader, participant, etc.), and the group name, if there were groups (ExGroup).

5 Specification – 3 (details)
This year’s camps will take place in different cities or villages (TakesPlace) (there are no two camps organized at the same place). It is important, when the camp starts (Starts), ends (Ends), the costs (Costs), the topic (groups will talk about, Topic), and there is also a symbolic homework (HomeWork). The limit of the number of participants (number_limit) depends on the places offered by the hosters. Altough there are four different age-groups, only two application models are separated: first the application for children, adolescents, juniors (Application_JUN) then for the seniors (Application_SEN). Groups (Grop) have names (GroupName), these groupnames are the same in all Children’s Camp. We can get the group leaders from their application and status, the number of the group is from the group schedule. During the camp there is a trip, where there will be three or four buses tranporting the people – in every bus, there are 3-4 groups (TripTogether). It is important to separate the planes of time. In an application, we get the constant datas of people, and also get datas only in connection with the application. So we shouldn’t mix for example the future camp-participants for the hosted children (other, different relations!). A child can be a participant in a camp, if his IsGoingThere attribute is 1, it is true, that he goes there.

6 Entities SZENTJANOSBOGAR ( BID, Name, AddrCity, AddrZip, AddrStreet, MobPhone, HomePhone, , BornPlace, BornDate, Class, ParsonName, ParishAddress, ParishPhone, ReligLeader, ParentName, ParentNotification, IllName, Medicine, WillHaveMedicine ); INHABITANT ( IID, Name, AddrCity, AddrZip, AddrStreet, MobPhone, HomePhone, WorkPhone, , DistanceFrom, Vehicle ); CAMPTHISYEAR ( CampType, TakesPlace, Starts, Ends, Costs, NumberLimit, HomeWork, Topic ); CHILDADOLJUNIOR ( TakesPlace ); SENIOR ( TakesPlace ); EVENT ( ExPlace, EventStarted, EventEnded, EventType ); ROOM ( RoomNo, Max ); GROP ( TakesPlace, GroupName );

7 Relations APPEARED ( BID, ExPlace, EventStarted, ExStatus, ExGroup );
ACCOMODATED ( BID, IID ); APPLICATION_JUN ( BID, TakesPlace, Status, Priority, ApplDate, IsGoingThere, CanPay, GettingTo, IsInhabitant ); APPLICATION_SEN ( BID, TakesPlace, CanPay, GettingTo ); GIVESHOME ( IID, TakesPlace, CanAccChild, CanAccMax, GirlBoyRate, Other ); GROUPMEMBER ( BID, TakesPlace, GroupName ); ROOMIN ( TakesPlace, RoomNo ); SLEEPIN ( BID, RoomNo ); TRIPTOGETHER ( TakesPlace, GroupName, BusID ); CLAIMTOBEIN1GROUP ( BID, BID2, G_ToBeOrNot ); CLAIMTOBEIN1HOME ( BID, BID2, H_ToBeOrNot ); { CLAIMTOHAVE1LEADER ( BID, BID2, L_ToBeOrNot ); }

8 ER-Diagram Outline, without the attributes…

9 …and complete, with the attributes

10 Functional Dependencies
Usually: F+ = { key(s) → ; trivials } Other cases: EVENT ( ExPlace, EventStarted, EventEnded, EventType ); FEvent+ = { ExPlace, EventStarted → ; EventType, EventStarted → ExPlace, EventEnded; EventType, EventEnded → EventStarted; trivials }. SZENTJANOSBOGAR ( BID, Name, AddrCity, AddrZip, AddrStreet, MobPhone, HomePhone, , BornPlace, BornDate, Class, ParsonName, ParishAddress, ParishPhone, ReligLeader, ParentName, ParentNotification, IllName, Medicine, WillHaveMedicine ); FSzentjanosbogar+ = { BID → ; Name, AddrCity, AddrStreet → ; AddrCity, AddrStreet → AddrZip; AddrStreet, AddrZip → AddrCity; ParsonName → ParishAddress, ParishPhone; ParishAddress → ParsonName, ParishPhone; ParishPhone → ParsonName, ParishPhone; trivials }. INHABITANT ( IID, Name, AddrCity, AddrZip, AddrStreet, MobPhone, HomePhone, WorkPhone, , DistanceFrom, Vehicle ); FInhabitant+ = { IID → ; Name, AddrCity, AddrStreet → ; AddrCity, AddrStreet → AddrZip; AddrStreet, AddrZip → AddrCity; trivials }. CAMPTHISYEAR ( CampType, TakesPlace, Starts, Ends, Costs, NumberLimit, Topic, HomeWork ); FCampThisYear+ = { TakesPlace → ; CampType → Start, Ends, Costs, Topic, HomeWork; trivials }. Comment: the "TakesPlace → CampType" dependency is the most important!

11 Normalization to BCNF – 1
E := Event, P = exPlace, S := eventStarted, E := eventEnded, T := eventType. E( P, S, E, T ); FE = { PS → ET, TS→E, TE→S } E11 = (T), E12 = (E), E13 (S); FE11 = FE12 = FE13 = { }. E2 = (TEP); FE2 = { }. C := CampThisYear; T := campType; P := takesPlace; N := NumberLimit;  := others { Starts, Ends, Costs, Topic, HomeWork }. C(T, P, N,  ); FC = { P → T,N,; T →  } C1 = (T, ); FC1 = { T →  }. C2 = (P, T, N); FC2 = { P → TN }.

12 Normalization to BCNF – 2
B := Szentjanosbogar; B := BID; N := Name; C := AddrCity; Z := AddrZip; S := AddrStreet; P := ParsonName, A := ParishAddress, F := ParishPhone;  := others { MobPhone, HomePhone, , BornPlace, BornDate, Class, ReligLeader, ParentName, ParentNotification, IllName, Medicine, WillHaveMedicine }. B(B, N, C, S, Z, P, A, F,  ); FB = { B → NCSZPAF; NCS → BZPAF; CS → Z; SZ → C; P → AF; A → PF; F → AP }. B11 = (P), B12 = (A), B13 (F); FB11 = FB12 = FB13 = { }. B2111 = (S, C), B2112 = (S, Z); FB2111 = FB2112 = { }. B212 = (N, S, C. P, ); FB212 = { NSC → P }. B221 = (B), B222 = (N, C, S); FB221 = FB222 = { }. I := Inhabitant; I := IID; N := Name; C := AddrCity; Z := AddrZip; S := AddrStreet;  := others { MobPhone, HomePhone, WorkPhone, , DistanceFrom, Vehicle }. I(I, N, C, S, Z,  ); FI = { I → NCSZ; NCS → IZ; CS → Z; SZ → C; }. I111 = (S, C), I112 = (S, Z); FI_111 = FI_112 = { }. I12 = (N, S, C. ); FI_12 = { NSC →  }. I21 = (I), I22 = (N, C, S); FI_21 = FI_22 = { }.

13 Creating Tables – 1 PROMPT Creating Entity Tables:
PROMPT - creating EVENT create table EVENT ( EVENTTYPE varchar2(20), EXPLACE varchar2(30) not null, EVENTSTARTED date not null, EVENTENDED date, primary key ( explace, eventstarted ) );

14 Creating Tables – 2 PROMPT - creating SZENTJANOSBOGAR
create table SZENTJANOSBOGAR ( BID number(5) unique, NAME varchar2(50) not null, ADDRCITY varchar2(30) not null, ADDRZIP number(5) not null, ADDRSTREET varchar2(50) not null, MOBPHONE varchar2(15), HOMEPHONE varchar2(15), varchar2(100), BORNPLACE varchar2(30) not null, BORNDATE date not null, CLASS number(2), PARSONNAME varchar2(40), PARISHADDRESS varchar2(100), PARISHPHONE varchar2(15), RELIGLEADER varchar2(40), PARENTNAME varchar2(50), PARENTNOTIFICATION varchar2(50), ILLNAME varchar2(50), MEDICINE varchar2(50), WILLHAVEMEDICINE number(1) -- boolean );

15 Creating Tables – 3 PROMPT - creating INHABITANT
create table INHABITANT ( IID number(5) primary key, NAME varchar2(50) not null, ADDRCITY varchar2(30) not null, ADDRZIP number(5) not null, ADDRSTREET varchar2(50) not null, MOBPHONE varchar2(15), HOMEPHONE varchar2(15), WORKPHONE varchar2(15), varchar2(100), DISTANCEFROM number(2), VEHICLE varchar2(10) );

16 Creating Tables – 4 PROMPT - creating CAMP-THIS-YEAR
create table CAMPTHISYEAR ( CAMPTYPE varchar2(18) not null, TAKESPLACE varchar2(20) primary key, STARTS date not null, ENDS date not null, COSTS number(5) not null, NUMBERLIMIT number(3), TOPIC varchar2(100), HOMEWORK varchar2(200) );

17 Creating Tables – 5 PROMPT - creating CHILD-ADOL-JUNIOR (is_a CampThisYear) create table CHILDADOLJUNIOR ( TAKESPLACE varchar2(20) primary key, foreign key ( takesplace ) references campthisyear( takesplace ) ); PROMPT - creating SENIOR (is_a CampThisYear) create table SENIOR

18 Creating Tables – 6 PROMPT - creating ROOM create table ROOM (
ROOMNO number(3) primary key, MAX number(2) ); PROMPT - creating GROP - like "Group" (weak entity) create table GROP TAKESPLACE varchar2(20) not null, GROUPNAME varchar2(30), primary key ( takesplace, groupname ), foreign key ( takesplace ) references campthisyear( takesplace )

19 Creating Tables – 7 PROMPT PROMPT Creating Relational Tables:
PROMPT - creating APPEARED (weak relation) create table APPEARED ( BID number(5) not null, EXPLACE varchar2(30) not null, EVENTSTARTED date not null, EXSTATUS varchar2(15), EXGROUP varchar2(30), foreign key (bid) references szentjanosbogar(bid), foreign key (explace, eventstarted) references event(explace, eventstarted) );

20 Creating Tables – 8 PROMPT - creating APPLICATION_JUNior' + child' + adolescent's create table APPLICATION_JUN ( BID number(5) not null, TAKESPLACE varchar2(20) not null, STATUS varchar2(15), PRIORITY number(1), APPLDATE date, ISGOINGTHERE number(1) default 1, CANPAY number(5) not null, GETTINGTO varchar2(20), ISINHABITANT number(1) default 0, -- boolean primary key ( bid, takesplace ), foreign key ( bid ) references szentjanosbogar( bid ), foreign key ( takesplace ) references childadoljunior( takesplace ) );

21 Creating Tables – 9 PROMPT - creating APPLICATION_SENior
create table APPLICATION_SEN ( BID number(5) not null, TAKESPLACE varchar2(20) not null references senior(takesplace), STATUS varchar2(15), CANPAY number(5) not null, GETTINGTO varchar2(20), primary key ( bid ), foreign key ( bid ) references szentjanosbogar(bid) );

22 Creating Tables – 10 PROMPT - creating ACCOMODATED
create table ACCOMODATED ( BID number(5) not null, IID number(5) not null references inhabitant (iid), primary key ( bid ), foreign key (bid) references szentjanosbogar(bid) ); PROMPT - creating GIVES-HOME create table GIVESHOME IID number(5) primary key references inhabitant(iid), TAKESPLACE varchar2(20) not null references childadoljunior(takesplace), CANACCCHILD number(2) not null, CANACCMAX number(2) not null, GIRLBOYRATE varchar2(20) not null, OTHER varchar2(300)

23 Creating Tables – 11 PROMPT - creating ROOM-IN create table ROOMIN (
TAKESPLACE varchar2(20) not null references senior(takesplace), ROOMNO number(3) primary key references room(roomno) ); PROMPT - creating SLEEP-IN create table SLEEPIN BID number(5) primary key references szentjanosbogar(bid), ROOMNO number(3) not null references room(roomno) PROMPT - creating GROUP-MEMBER create table GROUPMEMBER ( BID number(5), TAKESPLACE varchar2(20), GROUPNAME varchar2(30), primary key (bid, takesplace, groupname), foreign key (bid) references szentjanosbogar(bid), foreign key (groupname, takesplace) references grop( groupname, takesplace) );

24 Creating Tables – 12 PROMPT - creating TRIP-TOGETHER
create table TRIPTOGETHER --not perfect ( TAKESPLACE varchar2(20) not null, -- references grop(takesplace), WHICHGROUP varchar2(30), --references grop(groupname), WITHGROUP varchar2(30), --references grop(groupname), BUSID number(1) not null, primary key (takesplace, whichgroup, withgroup) ); PROMPT - creating CLAIM-TO-BE-IN-1-GROUP create table CLAIMTOBEIN1GROUP WHOBID number(5) not null references szentjanosbogar(bid), WITHBID number(5) not null references szentjanosbogar(bid), G_TOBEORNOT number(1) default 1, -- boolean primary key ( whobid, withbid ) PROMPT - creating CLAIM-TO-BE-IN-1-HOME create table CLAIMTOBEIN1HOME ( WHOBID number(5) not null references szentjanosbogar(bid), WITHBID number(5) not null references szentjanosbogar(bid), H_TOBEORNOT number(1) default 1, -- boolean primary key ( whobid, withbid ) ); /* PROMPT - creating CLAIM-TO-HAVE-1-LEADER create table CLAIMTOHAVE1LEADER BID number(5) not null references szentjanosbogar(bid), -- a lap kitöltője BID2 number(5) not null, -- akit (nem) akar L_TOBEORNOT number(1) default 1, -- bool primary key ( bid2 ), foreign key (bid2) references szentjanosbogar(bid) */

25 Inserting into Tables – 1
insert into szentjanosbogar values ( 1, 'Oltványi Gábor', 'Szeged', 6722, 'Kálvária sgt. 21.', ' ', ' ', 'Szeged', to_date(' ','DD-MM-YYYY'), 2, 'Tamás Barna SJ', 'Szeged, Bolyai u. 22.', '62-4??-???', '-', 'dr. Oltványi György', ' ', 'asztma', 'Ventolin', 1 ); insert into szentjanosbogar values ( 2, 'Börcsök Anikó', 'Jánossomorja', 1890, 'Nagybányai út 84.', ' ', ' ', 'Csömör', to_date(' ','DD-MM-YYYY'), 12, 'Kutasi Áron', null, null, null, null, null, null, null, null ); insert into szentjanosbogar values ( 3, 'Börcsök Csaba', 'Hidegség', 9677, 'Brassó utca 37.', ' ', ' ', 'Sajóbábony', to_date(' ','DD-MM-YYYY'), 3, 'Kutasi Géza', null, null, null, null, null, 'csípésallergia', 'Ventolin spray', 1 ); insert into szentjanosbogar values ( 4, 'Csillik Zsófia', 'Tápiószentmárton', 4124, 'Piac tér 88.', ' ', ' ', 'Nick', to_date(' ','DD-MM-YYYY'), 4, 'Tóth Mária', null, null, null, null, null, null, null, null ); insert into szentjanosbogar values ( 5, 'Csonka Katalin', 'Szelídi-tó (Soltvadkert)', 2784, 'Bakáts utca 72.', ' ', ' ', 'Gádoros', to_date(' ','DD-MM-YYYY'), 10, 'Görög József', null, null, null, null, null, 'vesebetegség', 'Calcium tabletta', 0 ); insert into szentjanosbogar values ( 6, 'Fodor Ernő', 'Füzesgyarmat', 2565, 'Kalmár Ilona sétány 24.', ' ', ' ', 'Kaposmérő', to_date(' ','DD-MM-YYYY'), 10, 'Hantosi Péter', null, null, null, null, null, null, null, null ); insert into szentjanosbogar values ( 7, 'Gyorgyovich János', 'Sopronhorpács', 9408, 'Enying utca 55.', ' ', ' ', 'Bordány', to_date(' ','DD-MM-YYYY'), 13, 'Bognár István', null, null, null, null, null, 'bokaficam', null, null); insert into inhabitant values( 1, 'Jójárt Szindi', 'Taksony', 1931, 'Mildenberger utca 81.', null, null, null, 14, 'gyalog' ); insert into inhabitant values( 2, 'Király Johanna', 'Taksony', 4926, 'Takaros utca 122.', null, null, null, 7, 'gyalog' ); insert into inhabitant values( 3, 'Gróf Fiadelfia', 'Taksony', 9752, 'Szinva utca 2.', null, null, null, null, 13, 'gyalog' ); insert into inhabitant values( 4, 'Nagy Malvina', 'Hosszúhetény', 9133, 'Hegytető utca 56.', null, null, null, 14, 'gyalog' ); insert into inhabitant values( 5, 'Sebők Emiliána', 'Hosszúhetény', 3602, 'Móra Ferenc utca 63.', null, null, null, null, 9, 'gyalog' ); insert into inhabitant values( 6, 'Barki Sába', 'Hosszúhetény', 7610, 'Páfrány forduló forduló 96.', null, null, null, null, 8, 'gyalog' ); insert into inhabitant values( 7, 'Pusztai Herold', 'Hosszúhetény', 1128, 'Szalóki utca 106.', null, null, null, 11, 'kerékpár'); insert into CampThisYear values( 'gyerektábor', 'Csanádapáca', to_date(' ','DD-MM-YYYY'), to_date(' ','DD-MM-YYYY'), 6300, 120, 'tálentumok', null ); insert into CampThisYear values( 'gyerektábor', 'Taksony', to_date(' ','DD-MM-YYYY'), to_date(' ','DD-MM-YYYY'), 6300, 100, 'tálentumok', null ); insert into CampThisYear values( 'gyerektábor', 'Mocsa', to_date(' ','DD-MM-YYYY'), to_date(' ','DD-MM-YYYY'), 6300, 130, 'tálentumok', null ); insert into CampThisYear values( 'gyerektábor', 'Hosszúhetény', to_date(' ','DD-MM-YYYY'), to_date(' ','DD-MM-YYYY'), 6300, 110, 'tálentumok', null ); insert into CampThisYear values( 'gyerektábor', 'Újdombóvár', to_date(' ','DD-MM-YYYY'), to_date(' ','DD-MM-YYYY'), 6300, 150, 'tálentumok', null ); insert into CampThisYear values( 'kamasztábor', 'Esztergom', to_date(' ','DD-MM-YYYY'), to_date(' ','DD-MM-YYYY'), 6300, 150, 'más1', null ); insert into CampThisYear values( 'ifitábor', 'Hajdúdorog', to_date(' ','DD-MM-YYYY'), to_date(' ','DD-MM-YYYY'), 7000, 140, 'más2', null ); insert into CampThisYear values( 'szeniortábor', 'Miskolc', to_date(' ','DD-MM-YYYY'), to_date(' ','DD-MM-YYYY'), 7000, 200, 'más3', null ); insert into event values( 'bál', 'Budapest', to_date(' ','DD-MM-YYYY'), to_date(' ','DD-MM-YYYY') ); insert into event values( 'bál', 'Budapest', to_date(' ','DD-MM-YYYY'), to_date(' ','DD-MM-YYYY') ); insert into event values( 'gyerektábor', 'Domaszék', to_date(' ','DD-MM-YYYY'), to_date(' ','DD-MM-YYYY') ); insert into event values( 'gyerektábor', 'Újkígyós', to_date(' ','DD-MM-YYYY'), to_date(' ','DD-MM-YYYY') ); insert into event values( 'gyerektábor', 'Egyházaskozár', to_date(' ','DD-MM-YYYY'), to_date(' ','DD-MM-YYYY') ); insert into event values( 'ifitábor', 'Herény', to_date(' ','DD-MM-YYYY'), to_date(' ','DD-MM-YYYY') ); insert into event values( 'közgyűlés', 'Budapest', to_date(' ','DD-MM-YYYY'), to_date(' ','DD-MM-YYYY') ); insert into event values( 'lelkigyakorlat', 'Dobogókő', to_date(' ','DD-MM-YYYY'), to_date(' ','DD-MM-YYYY') ); insert into event values( 'métabajnokság', 'Budapest', to_date(' ','DD-MM-YYYY'), to_date(' ','DD-MM-YYYY') ); insert into Room values( 205, 3 ); insert into room values( 210, 4 ); insert into room values( 313, 5 );

26 Inserting into Tables – 2
insert into ChildAdolJunior values ( 'Csanádapáca' ); insert into childadoljunior values ( 'Taksony' ); insert into childadoljunior values ( 'Mocsa' ); insert into childadoljunior values ( 'Hosszúhetény' ); insert into childadoljunior values ( 'Újdombóvár' ); insert into childadoljunior values ( 'Esztergom' ); insert into childadoljunior values ( 'Hajdúdorog' ); select * from childadoljunior; insert into Senior values ( 'Miskolc' ); select * from senior; insert into Grop values( 'Csanádapáca', 'messzirelátó' ); insert into GROP values( 'Taksony', 'messzirelátó' ); insert into GROP values( 'Mocsa', 'messzirelátó' ); insert into GROP values( 'Hosszúhetény', 'messzirelátó' ); insert into GROP values( 'Újdombóvár', 'messzirelátó' ); insert into GROP values( 'Csanádapáca', 'figyelmes' ); insert into GROP values( 'Taksony', 'figyelmes' ); insert into GROP values( 'Mocsa', 'figyelmes' ); Inserting into Tables – 3 insert into Application_JUN values( 1, 'Csanádapáca', 'főbogár', 1, to_date(' ','DD-MM-YYYY'), 1, 0, 'Bp - többiekkel', 0); insert into application_jun values( 1, 'Taksony', 'főbogár', 2, to_date(' ','DD-MM-YYYY'), 0, 0, 'Bp - többiekkel', 0 ); insert into application_jun values( 4, 'Esztergom', 'főbogár', 1, to_date(' ','DD-MM-YYYY'), 1, 0, 'Bp - többiekkel', 0 ); insert into application_jun values( 15, 'Csanádapáca', 'főbogár', 1, to_date(' ','DD-MM-YYYY'), 1, 0, 'kocsival', 0 ); insert into application_jun values( 15, 'Esztergom', 'főbogár', 2, to_date(' ','DD-MM-YYYY'), 0, 0, 'Bp - többiekkel', 0 ); insert into application_jun values( 1, 'Hajdúdorog', 'résztvevő', 1, to_date(' ','DD-MM-YYYY'), 1, null, 'kocsival', 0 ); insert into application_jun values( 21, 'Hajdúdorog', 'résztvevő', 1, to_date(' ','DD-MM-YYYY'), 1, null, 'Bp - többiekkel', 0 ); insert into application_jun values( 33, 'Hajdúdorog', 'résztvevő', 1, to_date(' ','DD-MM-YYYY'), 1, null, 'Bp - többiekkel', 0 ); insert into application_jun values( 34, 'Hajdúdorog', 'résztvevő', 1, to_date(' ','DD-MM-YYYY'), 1, null, 'kocsival', 0 ); insert into application_jun values( 3, 'Esztergom', 'résztvevő', 1, to_date(' ','DD-MM-YYYY'), 1, null, 'Bp - többiekkel', 0 ); insert into application_jun values( 31, 'Esztergom', 'résztvevő', 1, to_date(' ','DD-MM-YYYY'), 1, null, 'Bp - többiekkel', 0 ); insert into application_jun values( 32, 'Esztergom', 'résztvevő', 1, to_date(' ','DD-MM-YYYY'), 1, null, 'Bp - többiekkel', 0 ); insert into application_jun values( 2, 'Csanádapáca', 'résztvevő', 1, to_date(' ','DD-MM-YYYY'), 1, null, 'város - többiekkel', 0 ); insert into application_jun values( 2, 'Taksony', 'résztvevő', 2, to_date(' ','DD-MM-YYYY'), 0, null, 'kocsival', 0 ); insert into application_jun values( 3, 'Hosszúhetény', 'résztvevő', 2, to_date(' ','DD-MM-YYYY'), 0, null, 'Bp - többiekkel', 0 ); insert into application_jun values( 6, 'Taksony', 'résztvevő', 1, to_date(' ','DD-MM-YYYY'), 1, null, 'Bp - többiekkel', 0 ); insert into application_jun values( 7, 'Csanádapáca', 'résztvevő', 3, to_date(' ','DD-MM-YYYY'), 0, null, 'kocsival', 0 ); insert into application_jun values( 7, 'Újdombóvár', 'résztvevő', 2, to_date(' ','DD-MM-YYYY'), 0, null, 'Bp - többiekkel', 0 ); insert into application_jun values( 10, 'Csanádapáca', 'résztvevő', 3, to_date(' ','DD-MM-YYYY'), 1, null, 'város - többiekkel', 0 ); insert into application_jun values( 10, 'Mocsa', 'résztvevő', 1, to_date(' ','DD-MM-YYYY'), 0, null, 'kocsival', 0 ); insert into application_jun values( 11, 'Mocsa', 'résztvevő', 1, to_date(' ','DD-MM-YYYY'), 1, null, 'város - többiekkel', 0 ); insert into application_jun values( 11, 'Újdombóvár', 'résztvevő', 2, to_date(' ','DD-MM-YYYY'), 0, null, 'Bp - többiekkel', 0 ); insert into application_jun values( 12, 'Hosszúhetény', 'résztvevő', 3, to_date(' ','DD-MM-YYYY'), 0, null, 'város - többiekkel', 0 ); insert into Application_SEN values ( 8, 'Miskolc', 4000, 'kocsival' ); insert into Application_SEN values ( 23, 'Miskolc', 6000, 'Bp. - többiekkel' ); insert into Application_SEN values ( 37, 'Miskolc', 5500, 'Bp. - többiekkel' ); insert into Application_SEN values ( 1, 'Miskolc', 5000, 'Bp. - többiekkel' ); insert into Application_SEN(bid, takesplace, gettingto) values ( 9, 'Miskolc', 'Bp. - többiekkel' ); insert into Application_SEN(bid, takesplace, gettingto) values ( 22, 'Miskolc', 'Bp. - többiekkel' ); insert into Appeared values( 1, 'Mocsa', to_date(' ','DD-MM-YYYY'), 'főbogár', null ); insert into appeared values( 1, 'Budapest', to_date(' ','DD-MM-YYYY'), 'zenefelelős', null ); insert into appeared values( 3, 'Budapest', to_date(' ','DD-MM-YYYY'), 'szervező', null ); insert into appeared values( 5, 'Herény', to_date(' ','DD-MM-YYYY'), 'résztvevő', 'macska' ); insert into appeared values( 6, 'Szeged-Szentmihály', to_date(' ','DD-MM-YYYY'), 'résztvevő', 'elsőképzős' ); insert into appeared values( 6, 'Budapest', to_date(' ','DD-MM-YYYY'), 'résztvevő', null ); insert into RoomIn values ( 'Miskolc', 205 ); insert into RoomIn values ( 'Miskolc', 210 ); insert into RoomIn values ( 'Miskolc', 313 ); insert into GivesHome values ( 1, 'Taksony', 2, 4, 'x f y l', null ); insert into GivesHome values ( 2, 'Taksony', 2, 4, 'x f y l', null ); insert into GivesHome values ( 4, 'Hosszúhetény', 2, 5, 'x f y l', null); insert into GivesHome values ( 7, 'Hosszúhetény', 2, 6, 'x f y l', null ); insert into GivesHome values ( 9, 'Csanádapáca', 2, 4, 'x f y l', null ); insert into GivesHome values ( 12, 'Újdombóvár', 2, 3, 'x f y l', null); insert into GivesHome values ( 18, 'Esztergom', 2, 4, 'x f y l', null ); insert into GivesHome values ( 20, 'Mocsa', 2, 4, 'x f y l', null );

27 Inserting into Tables – 4
insert into GroupMember values ( 1, 'Csanádapáca', 'messzirelátó' ); insert into GroupMember values ( 2, 'Csanádapáca', 'figyelmes' ); insert into GroupMember values ( 3, 'Esztergom', 'farkas' ); insert into GroupMember values ( 4, 'Esztergom', 'nyúl' ); insert into GroupMember values ( 5, 'Hajdúdorog', 'arany' ); insert into GroupMember values ( 6, 'Hajdúdorog', 'gyémánt' ); insert into GroupMember values ( 7, 'Hosszúhetény', 'türelmes' ); insert into GroupMember values ( 8, 'Miskolc', 'helybentaláljákki1' ); insert into GroupMember values ( 9, 'Miskolc', 'helybentaláljákki2' ); insert into GroupMember values ( 10, 'Mocsa', 'figyelmes' ); insert into GroupMember values ( 11, 'Mocsa', 'türelmes' ); insert into GroupMember values ( 12, 'Taksony', 'messzirelátó' ); insert into GroupMember values ( 13, 'Újdombóvár', 'figyelmes' ); insert into GroupMember values ( 14, 'Újdombóvár', 'türelmes' ); insert into GroupMember values ( 15, 'Csanádapáca', 'messzirelátó' ); insert into GroupMember values ( 16, 'Csanádapáca', 'figyelmes' ); insert into GroupMember values ( 17, 'Esztergom', 'farkas' ); insert into GroupMember values ( 18, 'Esztergom', 'nyúl' ); insert into GroupMember values ( 19, 'Hajdúdorog', 'arany' ); insert into GroupMember values ( 20, 'Hajdúdorog', 'gyémánt' ); insert into GroupMember values ( 21, 'Hosszúhetény', 'türelmes' ); insert into GroupMember values ( 22, 'Miskolc', 'helybentaláljákki1' ); insert into GroupMember values ( 23, 'Miskolc', 'helybentaláljákki2' ); insert into GroupMember values ( 24, 'Mocsa', 'figyelmes' ); insert into GroupMember values ( 25, 'Mocsa', 'türelmes' ); insert into GroupMember values ( 26, 'Taksony', 'messzirelátó' ); insert into GroupMember values ( 27, 'Újdombóvár', 'figyelmes' ); insert into GroupMember values ( 28, 'Újdombóvár', 'türelmes' ); insert into GroupMember values ( 29, 'Csanádapáca', 'messzirelátó' ); insert into GroupMember values ( 30, 'Csanádapáca', 'figyelmes' ); insert into GroupMember values ( 31, 'Esztergom', 'farkas' ); insert into GroupMember values ( 32, 'Esztergom', 'nyúl' ); insert into GroupMember values ( 33, 'Hajdúdorog', 'arany' ); insert into GroupMember values ( 34, 'Hajdúdorog', 'gyémánt' ); insert into GroupMember values ( 35, 'Hosszúhetény', 'türelmes' ); insert into GroupMember values ( 36, 'Miskolc', 'helybentaláljákki1' ); insert into GroupMember values ( 37, 'Miskolc', 'helybentaláljákki2' ); insert into GroupMember values ( 38, 'Mocsa', 'figyelmes' ); insert into GroupMember values ( 39, 'Mocsa', 'türelmes' ); insert into GroupMember values ( 40, 'Taksony', 'messzirelátó' ); insert into GroupMember values ( 1, 'Hajdúdorog', 'gyémánt' ); insert into GroupMember values ( 1, 'Miskolc', 'helybentaláljákki1' ); insert into GroupMember values ( 3, 'Miskolc', 'helybentaláljákki2' ); insert into GroupMember values ( 4, 'Hajdúdorog', 'arany' ); insert into GroupMember values ( 6, 'Taksony', 'messzirelátó' ); insert into GroupMember values ( 7, 'Hajdúdorog', 'gyémánt' ); insert into GroupMember values ( 17, 'Csanádapáca', 'messzirelátó' ); insert into GroupMember values ( 21, 'Hajdúdorog', 'gyémánt' ); insert into GroupMember values ( 28, 'Miskolc', 'helybentaláljákki1' ); insert into GroupMember values ( 34, 'Csanádapáca', 'figyelmes' ); select * from GroupMember; insert into accomodated values ( 12, 1 ); insert into accomodated values ( 34, 1 ); insert into accomodated values ( 25, 1 ); insert into accomodated values ( 3, 2 ); insert into accomodated values ( 14, 2 ); insert into accomodated values ( 15, 3 ); insert into accomodated values ( 31, 3 ); insert into accomodated values ( 7, 4 ); insert into accomodated values ( 37, 4 ); insert into accomodated values ( 21, 5 ); insert into accomodated values ( 13, 5 ); insert into accomodated values ( 10, 6 ); insert into accomodated values ( 11, 6 ); insert into accomodated values ( 17, 7 ); insert into accomodated values ( 22, 7 ); insert into accomodated values ( 9, 8 ); insert into accomodated values ( 33, 8 ); insert into accomodated values ( 8, 9 ); insert into accomodated values ( 23, 9 ); insert into accomodated values ( 36, 10 ); insert into accomodated values ( 28, 10 ); insert into accomodated values ( 32, 11 ); insert into accomodated values ( 40, 11 ); insert into accomodated values ( 4, 12 ); insert into accomodated values ( 18, 12 ); insert into accomodated values ( 16, 13 ); insert into accomodated values ( 26, 13 ); insert into accomodated values ( 30, 14 ); insert into accomodated values ( 35, 14 ); insert into accomodated values ( 27, 15 ); insert into accomodated values ( 38, 15 ); insert into accomodated values ( 39, 16 ); insert into accomodated values ( 20, 16 ); insert into accomodated values ( 6, 17 ); insert into accomodated values ( 24, 17 ); insert into accomodated values ( 29, 18 ); insert into accomodated values ( 1, 18 ); insert into accomodated values ( 2, 19 ); insert into accomodated values ( 5, 19 ); insert into accomodated values ( 19, 20 ); select * from ACCOMODATED; insert into SleepIn values ( 8, 205 ); insert into SleepIn values ( 9, 210 ); insert into SleepIn values ( 22, 313 ); insert into SleepIn values ( 23, 205 ); insert into SleepIn values ( 36, 210 ); insert into SleepIn values ( 37, 313 ); insert into SleepIn values ( 1, 205 ); insert into SleepIn values ( 3, 210 ); insert into SleepIn values ( 28, 313 ); select * from SleepIn;

28 Selecting from Tables Where will be camps this summer? What kind are they? select camptype, takesplace from campthisyear order by camptype ; List the people applicate to camps! (ID, name, where, priority) prompt People applicated to Children's, Adolescents' or Juniors' Camp: select b.bid, name, takesplace, priority from szentjanosbogar b, application_jun a where a.bid = b.bid order by name prompt People applicated to Seniors' Camp: select b.bid, name, takesplace from szentjanosbogar b, application_sen a where b.bid = a.bid

29 Selecting from Tables Who has applicated to more than two camps? List them into descending order! (Don’t care the Seniors’ Camp!) SELECT name, COUNT(*) FROM szentjanosbogar b, application_jun a WHERE a.bid=b.bid HAVING count(*) > 2 GROUP BY name ORDER BY count(*) desc ; Who did applicate to Taksony? Is this their first marked place? select name, priority FROM szentjanosbogar b, application_jun a where a.bid=b.bid and takesplace='Taksony‘ order by name

30 Selecting from Tables Who will sleep in the same room during the Seniors’ Camp? Where are they from? select name, addrcity, roomno from szentjanosbogar b, sleepin s where b.bid = s.bid order by roomno ; List the groups in the camps this summer! (Name, Age, Group, Where) select name nev, to_char(BornDate, 'YYYY') ev, groupname csop, takesplace hely from szentjanosbogar b, groupmember gm where b.bid=gm.bid order by takesplace, groupname, név

31 Triggers CREATE TABLE Log ( Action VARCHAR(6), ActionTime DATE,
Source VARCHAR(25), Description VARCHAR(1000) ); CREATE OR REPLACE TRIGGER LogApplJun BEFORE DELETE OR UPDATE OR INSERT ON Application_JUN FOR EACH ROW DECLARE BEGIN IF DELETING THEN INSERT INTO Log(Action, ActionTime, Source, Description) VALUES('Delete', sysdate, 'Application_JUN', 'bid: ' || :OLD.BID || ' takesplace: ' || :OLD.takesplace || ' priority: ' || :OLD.priority); END IF; IF INSERTING THEN VALUES('Insert', sysdate, 'Application_JUN', 'bid: ' || :NEW.BID || ' takesplace: ' || :NEW.takesplace || ' priority: ' || :NEW.priority); IF UPDATING THEN VALUES('Update', sysdate, 'Application_JUN', 'bid: ' || :OLD.BID || ' takesplace: ' || :OLD.takesplace || ' priority: ' || :OLD.priority || ' -> ‘ || ‘bid: ' || :NEW.BID || ' takesplace: ' || :NEW.takesplace || ' priority: ' || :NEW.priority); END; / CREATE OR REPLACE TRIGGER LogApplSen BEFORE DELETE OR UPDATE OR INSERT ON Application_SEN FOR EACH ROW DECLARE BEGIN IF DELETING THEN INSERT INTO Log(Action, ActionTime, Source, Description) VALUES('Delete', sysdate, 'Application_SEN', 'bid: ' || :OLD.BID || ' takesplace: ' || :OLD.takesplace); END IF; IF INSERTING THEN VALUES('Insert', sysdate, 'Application_SEN', 'bid: ' || :NEW.BID || ' takesplace: ' || :NEW.takesplace); IF UPDATING THEN VALUES('Update', sysdate, 'Application_SEN', 'bid: ' || :OLD.BID || ' takesplace: ' || :OLD.takesplace || ' -> ' || 'bid: ' || :NEW.BID || ' takesplace: ' || :NEW.takesplace); END; /

32 The End See again from the beginning
This is the END of my project – show. What would You like to do? See again from the beginning See the Hungarian version (not finished yet) End show

33 Szentjánosbogár tábori jelentkezések adatbázisa
PPKE-ITK, II. évf., adatbázis-project tavasz Oltványi Gábor konzulens: Kaposi Benedek

34 Specifikáció – 1 Gyerekek (Szentjanosbogar) jelentkeznek idei nyári táborokba (CampThisYear), amiket az ország különböző területein (TakesPlace) szerveznek. Ezekben – a szeniortábor (CampThisYear/Senior) kivételével (tehát a gyerek-, kamasz- és ifitáborokban (CampThisYear/ChildAdolJunior)) – helybéli lakosok (Inhabitant) szállásolják el (Accomodating + GivesHome) a tábor résztvevőit. Szeniortáborban egy intézményben alszik (SleepIn) mindenki, szobákban (RoomIn) (Room: Number, Max person). Mindegyik tábor csoportokban (Grop) zajlik, a szenior kivételével vannak csoportvezetők. Öt gyerektábor, egy kamasztábor zajlik egy időben, a következő héten egy ifitábor, és később egy szeniortábor. Így a gyerektáborba jelentkezőknek meg kell adni egy sorrendet (Priority), hogy melyik helyszínen lévő táborba szeretnének inkább menni, ha betellne az első helyen megjelölt táborhelyszín, ugyanis korlátozott a helyi befogadók száma. Ezért a később jelentkezők (ApplDate) a másodikként bejelölt táborba tudnak csak menni véglegesen (IsGoingThere). Egy archívum is található, az egyes korábbi szentjánosbogár-rendezvényekről (Event), hogy ki hol volt (Appeared) eddig.

35 Specifikáció – 2 (részletek)
Egy jelentkező lehet résztvevő, szervező, tábori pap, szeniortáboron kívül csoportvezető, táborvezető és egyéb más posztú is (Status). A gyerek jelentkezési lapon a következő mezők vannak: név (Name), lakcím (AddrCity, AddrZip, AddrStreet), telefonszámok (MobPhone, HomePhone), ( ), születés helye (BornPlace), ideje (BornDate), osztály (Class), plébánosának neve (ParsonName), plébánia címe (ParishAddress), telefonszáma (ParishPhone), hittanára vagy bogárklub-vezetője (ReligLeader), betegsége (IllName), gyógyszer, ha szed (Medicine), visz-e magával a táborba (WillHaveMedicine), szülő/gondviselő neve (ParentName), elérhetősége (ParentNotification), mennyit tudnak befizetni (CanPay) a tábori költségbe – lehet többet is, kevesebbet is, mód szerint, és hogy mivel érkezik a táborba (GettingTo, ált. lehet: kocsival, Budapestről a többiekkel, környéki városból a többiekkel). A jelentkezőknek lehet igényük, hogy kivel (vagy kivel ne: H_ToBeOrNot, G_ToBeOrNot) kerüljenek egy szállásra (ClaimToBeIn1Home), vagy egy csoportba (ClaimToBeIn1Group), ill. ki (vagy ki ne: L_ToBeOrNot) legyen a csoportvezetőjük (ClaimToHave1Leader). A szállásadótól a néven, címen, telefonszámokon (+ WorkPhone) kívül megkérdezzük, hogy hány gyereket fogadnának be (CanAccChild), hányat végső esetben (CanAccMax), hogy milyen fiú-lány igényük van (GirlBoyRate), hány percre laknak a reggeli találkozóhelytől (DistanceFrom), és milyen járművel megközelíthető ez (Vehicle: gyalog, bicikli, kocsi, busz).

36 Specifikáció – 3 (részletek)
Egy korábbi eseményről a típusát (EventType: gyerektábor, kamasztábor, ifitábor, szeniortábor, ősbogártábor, bál, rajzás, métabajnokság, lelkigyakorlat, vezetőképző, táborelőkészítő nap, konditábor, játékklub, bogármise), helyszínét (ExPlace), kezdetét (EventStarted) és végét (EventEnded) tároljuk, az egyes megjelenteknél (Appeared) azt is, hogy milyen státuszban (ExStatus: szevező, főbogár, résztvevő, stb.), ill. ha volt, akkor az akkori csoportnevét is (ExGroup). Az idei táborok különböző helyszíneken (TakesPlace) szerveződnek évenként (egy évben nincs két tábor egy helyen), fontos a kezdete (Starts), vége (Ends), van egy költsége (Costs), témája (Topic), amihez egy jelképes házifeladatot kapnak a résztvevők (HomeWork). A létszámkorlát (number_limit) a szállásadók által nyújtott helyekből áll össze. Noha négy korosztály van megkülönböztetve, két jelentkezési sablon különül el: a gyerek-, kamasz- és ifitáboroké (Application_BOG) ill. a szeniortáboré (Application_SEN). A csoportoknak (Grop) neve van (GroupName), a csoportnevek azonosak az összes gyerektáborban. A csoportvezetők a jelentkezők státuszából jön ki, a létszám a csoportbeosztásból. A tábor során egy kirándulás is zajlik, aminek 3-4 busszal, buszonként 3-4 csoport (TripTogether) megy. Fontos még elkülöníteni az idősíkokat. A jelentkezéseknél kitöltődnek az állandó személyes adatok is, és olyan adatok is, amelyek csak a jelentkezésre vonatkoznak. Így nem szabad összeegyeztetnünk pl. a leendő táborosokat a már elszállásoltaktól. Akkor lesz tábori résztvevő valaki, ha az IsGoingThere attribútuma 1 vagyis igaz, hogy oda megy…

37


Letölteni ppt "Szentjánosbogár Camp Applications"

Hasonló előadás


Google Hirdetések