Veri Modelleme ve IliskiselVeritabanlari DersiProje Dökümanı                              Murat Gülci                     ...
1. Database E-R şeması
2. Database oluşturma                        Query                         ResultCREATE TABLE "REF_EQUIPMENT_TYPES"   (   ...
Query                           ResultCREATE TABLE "SUPPORT_STAFF"   (    "STAFF_ID" NUMBER(5,0),        "DATE_JOINED" DAT...
CREATE TABLE "PROBLEMS"   (    "PROBLEM_ID" NUMBER(10,0) NOT NULL ENABLE,        "EQUIPMENT_ID" NUMBER(10,0) NOT NULL ENAB...
3. Table’lara kısıt ekleme                         Query                           ResultALTER TABLE "STAFF_SKILLS" ADD CO...
Query                          ResultALTER TABLE "RESOLUTIONS" ADD CONSTRAINT"RESOLUTIONS_FK" FOREIGN KEY ("PROBLEM_HISTOR...
4. Select Sorgular           a. En Sorunlu ürünlerQuerySelect  REF_EQUIPMENT_TYPES.EQUIPMENT_TYPE_DESCRIPTION,  EQUIPMENT....
b. En çok sorun çözen IT elemanlarıQuerySelect  SUPPORT_STAFF.STAFF_ID,  SUPPORT_STAFF.STAFF_NAME,  SUPPORT_STAFF.STAFF_EM...
d. Açık Çağrılar ListesiQuerySelect  PROBLEM_HISTORY.PROBLEM_HISTORY_ID,  REF_PRIORITY_LEVELS.PRIORITY_LEVEL_DESCRIPTION, ...
f. 40000000007 no’lu problemin geçmiş detayıQuerySelect  PROBLEMS.PROBLEM_ID,  PROBLEMS.PROBLEM_DESCRIPTION,  REF_PRIORITY...
h. Geçen Seneki çağrıların toplamıQuerySelect  Count(Distinct PROBLEM_HISTORY.PROBLEM_ID) as "2011 Çağrı Adedi"From  PROBL...
j. Kapatılan ÇağrılarQuerySelect  PROBLEMS.PROBLEM_ID,  USERS.USER_FIRST_NAME,  USERS.USER_LAST_NAME,  EQUIPMENT.EQUIPMENT...
l. Problem çözümü girilmiş problemlerin listesiQuerySelect Distinct  PROBLEM_HISTORY.PROBLEM_IDFrom  PROBLEM_HISTORYOrder ...
5. Update sorguları               a. Açık çağrıların kapatılmasıQueryupdate problem_historyset problem_status_code =  (sel...
b. Çözüm girilen çağrıların kapatılmasıQueryupdate problem_historyset problem_status_code =  (select problem_status_code  ...
d. User’ın type’ı değişmesi(müdür olması)QueryINSERT INTO ref_user_types VALUES (6000000006,Muhasebe Müdürü)update users  ...
f.   equipment_code(seri no) değiştirilmesiQueryupdate EQUIPMENT    set EQUIPMENT_CODE = 2000000006where    EQUIPMENT_CODE...
h. equipment silinmesiQueryALTER TABLE      "PROBLEMS" disable CONSTRAINT "PROBLEMS_FK"Table altered. 0.03 secondsdelete  ...
k.   Support Stuff silinmesiQuerydelete    from support_staff    where staff_id=1001 and staff_name = MustafaResult1 row(s...
m. Case kullanmakQueryselect    problem_history_id, PROBLEM_HISTORY_DESCRIPTION,    case    when ASSIGNED_STAFF_ID= 1001 t...
6. Extra Sorgular                a. Genel Bakış view oluşturmaQueryCREATE OR REPLACE VIEW genel_bakisASSelect PROBLEM_HIST...
b. Index OluşturmaQueryCREATE INDEX problem__id_index ON problem_history(problem_id);ResultIndex created.                 ...
Upcoming SlideShare
Loading in...5
×

Oracle helpdesk database shema

228

Published on

Oracle ile helpdesk database hazırlamıştım zamanında. size de faydası olur diye yüklüyorum.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
228
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Oracle helpdesk database shema

  1. 1. Veri Modelleme ve IliskiselVeritabanlari DersiProje Dökümanı Murat Gülci Bu projede bir Helpdesk database’i tasarlandı ve oluşturuldu. Kullanıcıların takibi, problemlerin ve problemin geçmişinin takibi, envanter takibi ve Bilgi işlem çalışanlarının yeteneklerinin takibi yapılabilmesi sağlandı.Hazırlanan bütün sorgular, karşılaşılabilinecek gerçek senaryolar düşünülerek hazırlandı. Bahceşehir Üniversitesi BEŞİKTAŞ ALPER TUNGA Veritabanı ve İlişkisel Veritabanları YZM5507
  2. 2. 1. Database E-R şeması
  3. 3. 2. Database oluşturma Query ResultCREATE TABLE "REF_EQUIPMENT_TYPES" ( "EQUIPMENT_TYPE_CODE" NUMBER(5,0), "EQUIPMENT_TYPE_DESCRIPTION" VARCHAR2(50), PRIMARY KEY ("EQUIPMENT_TYPE_CODE") ENABLE ) ; Query ResultCREATE TABLE "REF_SKILL_CODES" ( "SKILL_CODE" NUMBER(5,0), "SKILL_DESCRIPTION" VARCHAR2(50), PRIMARY KEY ("SKILL_CODE") ENABLE ) ; Query ResultCREATE TABLE "STAFF_SKILLS" ( "STAFF_ID" NUMBER(5,0), "SKILL_CODE" NUMBER(5,0), "DATE_SKILL_OBTAINED" DATE, PRIMARY KEY ("STAFF_ID") ENABLE ) ; Query ResultCREATE TABLE "EQUIPMENT" ( "EQUIPMENT_ID" NUMBER, "EQUIPMENT_TYPE_CODE" NUMBER, "DATA_EQUIPMENT_ACQUIRED" DATE, "DATE_EQUIPMENT_DISPOSED" DATE, "EQUIPMENT_CODE" NUMBER(10,0), "EQUIPMENT_NAME" CHAR(20), "EQUIPMENT_DESCRIPTION" VARCHAR2(50), "MANUFACTURER_NAME" CHAR(20), CONSTRAINT "EQUIPMENT_PK" PRIMARY KEY("EQUIPMENT_ID") ENABLE )
  4. 4. Query ResultCREATE TABLE "SUPPORT_STAFF" ( "STAFF_ID" NUMBER(5,0), "DATE_JOINED" DATE, "DATE_LEFT" DATE, "STAFF_NAME" CHAR(40), "STAFF_PHONE" NUMBER(10,0), "STAFF_EMAIL" CHAR(50), "STAFF_LOCATION" CHAR(10), PRIMARY KEY ("STAFF_ID") ENABLE ) ; Query ResultCREATE TABLE "REF_USER_TYPES" ( "USER_TYPE_CODE" NUMBER(10,0), "USER_TYPE_DESCRIPTION" VARCHAR2(50), PRIMARY KEY ("USER_TYPE_CODE") ENABLE ) ; Query ResultCREATE TABLE "REF_PRIORITY_LEVELS" ( "PROBLEM_LEVEL_CODE" NUMBER(3,0), "PRIORITY_LEVEL_DESCRIPTION" VARCHAR2(10), PRIMARY KEY ("PROBLEM_LEVEL_CODE") ENABLE ) ; Query ResultCREATE TABLE "REF_PROBLEM_STATUS_CODE" ( "PROBLEM_STATUS_CODE" NUMBER(3,0), "PROBLEM_STATUS_DESCRIPTION" VARCHAR2(10), PRIMARY KEY ("PROBLEM_STATUS_CODE") ENABLE ) ; Query ResultCREATE TABLE "USERS" ( "USER_ID" NUMBER(5,0), "USER_TYPE_CODE" NUMBER(10,0), "USER_FIRST_NAME" CHAR(20), "USER_LAST_NAME" CHAR(20), "USER_PHONE" NUMBER(10,0), "USER_EMAIL" CHAR(50), "ADDRESS" VARCHAR2(100), CONSTRAINT "USERS_PK" PRIMARY KEY ("USER_ID")ENABLE ); Query Result
  5. 5. CREATE TABLE "PROBLEMS" ( "PROBLEM_ID" NUMBER(10,0) NOT NULL ENABLE, "EQUIPMENT_ID" NUMBER(10,0) NOT NULL ENABLE, "USER_ID" NUMBER(5,0) NOT NULL ENABLE, "PROBLEM_REPORTED_DATETIME" DATE NOT NULLENABLE, "PROBLEM_DESCRIPTION" VARCHAR2(500) NOT NULLENABLE, CONSTRAINT "PROBLEMS_PK" PRIMARY KEY("PROBLEM_ID") ENABLE ); Query ResultCREATE TABLE "PROBLEM_HISTORY" ( "PROBLEM_HISTORY_ID" NUMBER(10,0) NOT NULLENABLE, "PRIORITY_LEVEL_CODE" NUMBER(3,0) NOT NULLENABLE, "PROBLEM_ID" NUMBER(10,0) NOT NULL ENABLE, "PROBLEM_STATUS_CODE" NUMBER(3,0) NOT NULLENABLE, "ASSIGNED_STAFF_ID" NUMBER(5,0) NOT NULLENABLE, "FIX_DATETIME" DATE NOT NULL ENABLE, "PROBLEM_HISTORY_DESCRIPTION" VARCHAR2(500)NOT NULL ENABLE, CONSTRAINT "PROBLEM_HISTORY_PK" PRIMARY KEY("PROBLEM_HISTORY_ID") ENABLE ); Query ResultCREATE TABLE "RESOLUTIONS" ( "RESOLUTION_ID" NUMBER(10,0) NOT NULL ENABLE, "PROBLEM_HISTORY_ID" NUMBER(10,0), "RESOLUTION_DESCRIPTION" VARCHAR2(500), CONSTRAINT "RESOLUTIONS_PK" PRIMARY KEY("RESOLUTION_ID") ENABLE ) ;
  6. 6. 3. Table’lara kısıt ekleme Query ResultALTER TABLE "STAFF_SKILLS" ADD CONSTRAINT"STAFF_SKILLS_CON" FOREIGN KEY ("SKILL_CODE")REFERENCES "REF_SKILL_CODES" ("SKILL_CODE") ENABLE; Query ResultALTER TABLE "EQUIPMENT" ADD CONSTRAINT"EQUIPMENT_CON" FOREIGN KEY ("EQUIPMENT_TYPE_CODE") REFERENCES "REF_EQUIPMENT_TYPES"("EQUIPMENT_TYPE_CODE") ENABLE; Query ResultALTER TABLE "PROBLEMS" ADD CONSTRAINT "PROBLEMS_CON"FOREIGN KEY ("USER_ID") REFERENCES "USERS" ("USER_ID") ENABLE;ALTERTABLE "PROBLEMS" ADD CONSTRAINT "PROBLEMS_FK" FOREIGNKEY ("EQUIPMENT_ID") REFERENCES "EQUIPMENT" ("EQUIPMENT_ID")ENABLE; Query ResultALTER TABLE "PROBLEM_HISTORY" ADD CONSTRAINT"PROBLEM_HISTORY_FK" FOREIGN KEY("PRIORITY_LEVEL_CODE") REFERENCES "REF_PRIORITY_LEVELS"("PROBLEM_LEVEL_CODE") ENABLE;ALTER TABLE"PROBLEM_HISTORY" ADD CONSTRAINT "PROBLEM_HISTORY_FK2"FOREIGN KEY ("PROBLEM_ID") REFERENCES "PROBLEMS" ("PROBLEM_ID")ENABLE;ALTER TABLE "PROBLEM_HISTORY" ADD CONSTRAINT"PROBLEM_HISTORY_FK3" FOREIGN KEY("PROBLEM_STATUS_CODE") REFERENCES "REF_PROBLEM_STATUS_CODE"("PROBLEM_STATUS_CODE") ENABLE;ALTER TABLE"PROBLEM_HISTORY" ADD CONSTRAINT "PROBLEM_HISTORY_FK4"FOREIGN KEY ("ASSIGNED_STAFF_ID") REFERENCES "SUPPORT_STAFF" ("STAFF_ID")ENABLE;
  7. 7. Query ResultALTER TABLE "RESOLUTIONS" ADD CONSTRAINT"RESOLUTIONS_FK" FOREIGN KEY ("PROBLEM_HISTORY_ID") REFERENCES "PROBLEM_HISTORY"("PROBLEM_HISTORY_ID") ENABLE; Query ResultALTER TABLE "USERS" ADD CONSTRAINT "USERS_FK" FOREIGNKEY ("USER_TYPE_CODE") REFERENCES "REF_USER_TYPES"("USER_TYPE_CODE") ENABLE;
  8. 8. 4. Select Sorgular a. En Sorunlu ürünlerQuerySelect REF_EQUIPMENT_TYPES.EQUIPMENT_TYPE_DESCRIPTION, EQUIPMENT.EQUIPMENT_TYPE_CODE, EQUIPMENT.EQUIPMENT_NAME, EQUIPMENT.EQUIPMENT_DESCRIPTION, PROBLEMS.EQUIPMENT_ID As EQUIPMENT_ID1, Count(PROBLEMS.EQUIPMENT_ID) as "Problem Sayısı"From EQUIPMENT Inner Join REF_EQUIPMENT_TYPES On EQUIPMENT.EQUIPMENT_TYPE_CODE = REF_EQUIPMENT_TYPES.EQUIPMENT_TYPE_CODE Inner Join PROBLEMS On PROBLEMS.EQUIPMENT_ID = EQUIPMENT.EQUIPMENT_IDWhere PROBLEMS.EQUIPMENT_ID = EQUIPMENT.EQUIPMENT_IDGroup By REF_EQUIPMENT_TYPES.EQUIPMENT_TYPE_DESCRIPTION, EQUIPMENT.EQUIPMENT_TYPE_CODE, EQUIPMENT.EQUIPMENT_NAME, EQUIPMENT.EQUIPMENT_DESCRIPTION, PROBLEMS.EQUIPMENT_IDOrder By Count(PROBLEMS.EQUIPMENT_ID) DescQuery 2:select EQUIPMENT_ID, count(EQUIPMENT_ID)from problemsgroup by EQUIPMENT_IDhaving count(EQUIPMENT_ID)>1order by count(EQUIPMENT_ID) descResultResult 2
  9. 9. b. En çok sorun çözen IT elemanlarıQuerySelect SUPPORT_STAFF.STAFF_ID, SUPPORT_STAFF.STAFF_NAME, SUPPORT_STAFF.STAFF_EMAIL, REF_SKILL_CODES.SKILL_DESCRIPTION, Count(PROBLEM_HISTORY.ASSIGNED_STAFF_ID) as "Sorun Sayısı"From PROBLEM_HISTORY Inner Join SUPPORT_STAFF On PROBLEM_HISTORY.ASSIGNED_STAFF_ID = SUPPORT_STAFF.STAFF_ID Inner Join STAFF_SKILLS On STAFF_SKILLS.STAFF_ID = SUPPORT_STAFF.STAFF_ID Inner Join REF_SKILL_CODES On STAFF_SKILLS.SKILL_CODE = REF_SKILL_CODES.SKILL_CODEGroup By SUPPORT_STAFF.STAFF_ID, SUPPORT_STAFF.STAFF_NAME, SUPPORT_STAFF.STAFF_EMAIL, REF_SKILL_CODES.SKILL_DESCRIPTIONOrder By Count(PROBLEM_HISTORY.ASSIGNED_STAFF_ID) DescResult c. En sorunlu KullanıcılarQuerySelect USERS.USER_ID, USERS.USER_FIRST_NAME, USERS.USER_LAST_NAME, USERS.USER_EMAIL, REF_USER_TYPES.USER_TYPE_DESCRIPTION, Count(PROBLEMS.USER_ID) As Problem_CountFrom PROBLEMS Inner Join USERS On PROBLEMS.USER_ID = USERS.USER_ID Inner Join REF_USER_TYPES On USERS.USER_TYPE_CODE = REF_USER_TYPES.USER_TYPE_CODEGroup By USERS.USER_ID, USERS.USER_FIRST_NAME, USERS.USER_LAST_NAME, USERS.USER_EMAIL, REF_USER_TYPES.USER_TYPE_DESCRIPTIONOrder By Count(PROBLEMS.USER_ID) DescResult
  10. 10. d. Açık Çağrılar ListesiQuerySelect PROBLEM_HISTORY.PROBLEM_HISTORY_ID, REF_PRIORITY_LEVELS.PRIORITY_LEVEL_DESCRIPTION, SUPPORT_STAFF.STAFF_NAME, PROBLEMS.PROBLEM_DESCRIPTION, PROBLEM_HISTORY.PROBLEM_HISTORY_DESCRIPTION, REF_PROBLEM_STATUS_CODE.PROBLEM_STATUS_DESCRIPTIONFrom PROBLEM_HISTORY Inner Join REF_PROBLEM_STATUS_CODE On PROBLEM_HISTORY.PROBLEM_STATUS_CODE = REF_PROBLEM_STATUS_CODE.PROBLEM_STATUS_CODE Inner Join SUPPORT_STAFF On PROBLEM_HISTORY.ASSIGNED_STAFF_ID = SUPPORT_STAFF.STAFF_ID Inner Join REF_PRIORITY_LEVELS On PROBLEM_HISTORY.PRIORITY_LEVEL_CODE = REF_PRIORITY_LEVELS.PROBLEM_LEVEL_CODE Inner Join PROBLEMS On PROBLEM_HISTORY.PROBLEM_ID = PROBLEMS.PROBLEM_IDWhere PROBLEM_HISTORY.PROBLEM_STATUS_CODE = 803Result e. SLA süresinde çözülmeyen işlerQuerySelect PROBLEMS.PROBLEM_ID, PROBLEMS.PROBLEM_REPORTED_DATETIME, PROBLEM_HISTORY.FIX_DATETIME, USERS.USER_FIRST_NAME, USERS.USER_LAST_NAME, PROBLEMS.PROBLEM_DESCRIPTION, REF_PRIORITY_LEVELS.PRIORITY_LEVEL_DESCRIPTIONFrom PROBLEMS Inner Join PROBLEM_HISTORY On PROBLEM_HISTORY.PROBLEM_ID = PROBLEMS.PROBLEM_ID Inner Join REF_PRIORITY_LEVELS On PROBLEM_HISTORY.PRIORITY_LEVEL_CODE = REF_PRIORITY_LEVELS.PROBLEM_LEVEL_CODE Inner Join USERS On PROBLEMS.USER_ID = USERS.USER_IDWhere PROBLEM_HISTORY.FIX_DATETIME > PROBLEMS.PROBLEM_REPORTED_DATETIMEResult
  11. 11. f. 40000000007 no’lu problemin geçmiş detayıQuerySelect PROBLEMS.PROBLEM_ID, PROBLEMS.PROBLEM_DESCRIPTION, REF_PRIORITY_LEVELS.PRIORITY_LEVEL_DESCRIPTION, REF_PROBLEM_STATUS_CODE.PROBLEM_STATUS_DESCRIPTION, PROBLEM_HISTORY.FIX_DATETIME, SUPPORT_STAFF.STAFF_NAME, PROBLEM_HISTORY.PROBLEM_HISTORY_DESCRIPTIONFrom PROBLEMS Inner Join PROBLEM_HISTORY On PROBLEM_HISTORY.PROBLEM_ID = PROBLEMS.PROBLEM_ID Inner Join REF_PROBLEM_STATUS_CODE On PROBLEM_HISTORY.PROBLEM_STATUS_CODE = REF_PROBLEM_STATUS_CODE.PROBLEM_STATUS_CODE Inner Join REF_PRIORITY_LEVELS On PROBLEM_HISTORY.PRIORITY_LEVEL_CODE = REF_PRIORITY_LEVELS.PROBLEM_LEVEL_CODE Inner Join SUPPORT_STAFF On PROBLEM_HISTORY.ASSIGNED_STAFF_ID = SUPPORT_STAFF.STAFF_IDWhere PROBLEMS.PROBLEM_ID = 4000000007Result g. Ahmet Kullanıcısının Çağrılarının detaylarıQuerySelect USERS.USER_FIRST_NAME, USERS.USER_LAST_NAME, PROBLEMS.PROBLEM_DESCRIPTION, PROBLEM_HISTORY.FIX_DATETIME, PROBLEM_HISTORY.PROBLEM_HISTORY_DESCRIPTION, REF_PRIORITY_LEVELS.PRIORITY_LEVEL_DESCRIPTIONFrom USERS Inner Join PROBLEMS On PROBLEMS.USER_ID = USERS.USER_ID Inner Join PROBLEM_HISTORY On PROBLEM_HISTORY.PROBLEM_ID = PROBLEMS.PROBLEM_ID Inner Join REF_PRIORITY_LEVELS On PROBLEM_HISTORY.PRIORITY_LEVEL_CODE = REF_PRIORITY_LEVELS.PROBLEM_LEVEL_CODEWhere USERS.USER_FIRST_NAME = AhmetQuery_2select PROBLEM_ID, PROBLEM_DESCRIPTIONfrom problems p, users uwhere p.user_id = u.user_id and u.user_first_name like Ahme%ResultResult2
  12. 12. h. Geçen Seneki çağrıların toplamıQuerySelect Count(Distinct PROBLEM_HISTORY.PROBLEM_ID) as "2011 Çağrı Adedi"From PROBLEMS Inner Join PROBLEM_HISTORY On PROBLEM_HISTORY.PROBLEM_ID = PROBLEMS.PROBLEM_IDWhere Extract(Year From PROBLEM_HISTORY.FIX_DATETIME) = 2011Result i. Atanmamış çağrılarQuerySelect EQUIPMENT.EQUIPMENT_NAME, USERS.USER_FIRST_NAME, USERS.USER_LAST_NAME, PROBLEMS.PROBLEM_REPORTED_DATETIME, PROBLEMS.PROBLEM_DESCRIPTIONFrom PROBLEMS Inner Join EQUIPMENT On PROBLEMS.EQUIPMENT_ID = EQUIPMENT.EQUIPMENT_ID Inner Join USERS On PROBLEMS.USER_ID = USERS.USER_IDWhere PROBLEMS.PROBLEM_ID Not In (Select Distinct (PROBLEM_HISTORY.PROBLEM_ID) From PROBLEM_HISTORY)Result
  13. 13. j. Kapatılan ÇağrılarQuerySelect PROBLEMS.PROBLEM_ID, USERS.USER_FIRST_NAME, USERS.USER_LAST_NAME, EQUIPMENT.EQUIPMENT_NAME, REF_EQUIPMENT_TYPES.EQUIPMENT_TYPE_DESCRIPTION, PROBLEM_HISTORY.PROBLEM_HISTORY_DESCRIPTIONFrom PROBLEMS Inner Join PROBLEM_HISTORY On PROBLEM_HISTORY.PROBLEM_ID = PROBLEMS.PROBLEM_ID Inner Join USERS On PROBLEMS.USER_ID = USERS.USER_ID Inner Join EQUIPMENT On PROBLEMS.EQUIPMENT_ID = EQUIPMENT.EQUIPMENT_ID Inner Join REF_EQUIPMENT_TYPES On EQUIPMENT.EQUIPMENT_TYPE_CODE = REF_EQUIPMENT_TYPES.EQUIPMENT_TYPE_CODEWhere PROBLEM_HISTORY.PROBLEM_STATUS_CODE = 804Result k. Zor seviyesindeki çağrıların detay durumuQuerySelect PROBLEMS.PROBLEM_ID, USERS.USER_FIRST_NAME, USERS.USER_LAST_NAME, PROBLEMS.PROBLEM_DESCRIPTION, PROBLEM_HISTORY.PROBLEM_HISTORY_DESCRIPTION, SUPPORT_STAFF.STAFF_NAMEFrom PROBLEM_HISTORY Inner Join PROBLEMS On PROBLEM_HISTORY.PROBLEM_ID = PROBLEMS.PROBLEM_ID Inner Join USERS On PROBLEMS.USER_ID = USERS.USER_ID Inner Join SUPPORT_STAFF On PROBLEM_HISTORY.ASSIGNED_STAFF_ID = SUPPORT_STAFF.STAFF_IDWhere PROBLEM_HISTORY.PRIORITY_LEVEL_CODE = 703Result
  14. 14. l. Problem çözümü girilmiş problemlerin listesiQuerySelect Distinct PROBLEM_HISTORY.PROBLEM_IDFrom PROBLEM_HISTORYOrder By PROBLEM_HISTORY.PROBLEM_IDResult
  15. 15. 5. Update sorguları a. Açık çağrıların kapatılmasıQueryupdate problem_historyset problem_status_code = (select problem_status_code from ref_problem_status_code where problem_status_description=kapandı)where problem_status_code in (select p.problem_status_code from problem_history p, ref_problem_status_code s where problem_status_description=açık ands.problem_status_code=p.problem_status_code)Result
  16. 16. b. Çözüm girilen çağrıların kapatılmasıQueryupdate problem_historyset problem_status_code = (select problem_status_code from ref_problem_status_code where problem_status_description=kapandı)where problem_status_code in (select h.problem_status_code from problem_history h, resolutions r where r.problem_history_id=h.problem_history_id)Result c. Support Elemanına skill ekleme ve tarihi güncellemeQueryINSERT INTO ref_skill_codes VALUES (3006,Senior Programmer);update staff_skills set (skill_code, date_skill_obtained) = (select skill_code, to_date(sysdate, dd/mm/yyyy ) from ref_skill_codes where skill_description=Senior Programmer )where skill_code = (select st.skill_code from staff_skills st, support_staff su where st.staff_id=su.staff_id and su.staff_name=Murat);Result
  17. 17. d. User’ın type’ı değişmesi(müdür olması)QueryINSERT INTO ref_user_types VALUES (6000000006,Muhasebe Müdürü)update users set USER_TYPE_CODE = ( select user_type_code from ref_user_types where USER_TYPE_DESCRIPTION = Muhasebe Müdürü)where USER_TYPE_CODE = (select USER_TYPE_CODE from users where user_id=30003 and user_first_name=Eyüp)Result1 row(s) updated. 0.00 seconds select u.user_first_name, ru.USER_TYPE_DESCRIPTION from users u, ref_user_types ru where u.user_id=30003 and u.user_type_code=ru.user_type_code; e. Prblem açıklaması değiştirilmesiQueryupdate problems set PROBLEM_DESCRIPTION = Yazıcıya yazdırırken yazdırılamadı şeklindehata veriyor. dün çalışıyordu,sorun yoktuwhere problem_id = 4000000001Result1 row(s) updated. 0.02 secondsselect problem_id, PROBLEM_DESCRIPTION from problems where problem_id=4000000001
  18. 18. f. equipment_code(seri no) değiştirilmesiQueryupdate EQUIPMENT set EQUIPMENT_CODE = 2000000006where EQUIPMENT_CODE = 2000000005 and EQUIPMENT_ID = 1000000005Result1 row(s) updated. 0.03 secondsselect EQUIPMENT_ID, EQUIPMENT_CODE from EQUIPMENT where EQUIPMENT_ID =1000000005 g. Support elemanlarına yeni sorun atanmasıQueryselect p.problem_id from problems p where p.problem_id not in (select problem_id from problem_history)INSERT INTO problem_history VALUES (5000000011,701, (select p.problem_id from problems p where p.problem_id not in(select problem_id from problem_history)), 802,1002, TO_DATE (06/06/2011, dd/mm/yyyy),xc)Result1 row(s) inserted. 0.06 secondsselect p.problem_id from problems p where p.problem_id not in (select problem_idfrom problem_history)no data found
  19. 19. h. equipment silinmesiQueryALTER TABLE "PROBLEMS" disable CONSTRAINT "PROBLEMS_FK"Table altered. 0.03 secondsdelete from equipment where EQUIPMENT_ID=1000000002Result1 row(s) deleted. 0.01 seconds i. user silinmesiQueryALTER TABLE "PROBLEMS" disable CONSTRAINT "PROBLEMS_CON"Table altered. 0.08 secondsdelete from users where user_first_name=Ayşe and user_last_name=Cebeci anduser_id=30005Result1 row(s) deleted. 0.01 seconds j. Problem History Kaydı silinmesiQuerydelete from problem_history where PROBLEM_HISTORY_ID= 5000000006Result1 row(s) deleted. 0.01 seconds
  20. 20. k. Support Stuff silinmesiQuerydelete from support_staff where staff_id=1001 and staff_name = MustafaResult1 row(s) deleted. 0.01 seconds l. Sorun İstatistikleriQueryselect min(count(p.ASSIGNED_STAFF_ID)) as "En az Sorunla İlgilenen", max(count(p.ASSIGNED_STAFF_ID)) as "En Fazla Sorunla İlgilenen", round(avg(count(p.ASSIGNED_STAFF_ID)),1) as "Ortama Sorunla İlgilenen"from problem_history pgroup by p.ASSIGNED_STAFF_IDResult
  21. 21. m. Case kullanmakQueryselect problem_history_id, PROBLEM_HISTORY_DESCRIPTION, case when ASSIGNED_STAFF_ID= 1001 then Mustafa ilgileniyor when ASSIGNED_STAFF_ID= 1002 then Dinçer ilgileniyor when ASSIGNED_STAFF_ID= 1003 then Şükrü ilgileniyor else Başkası ilgileniyor end as Kim_ilgileniyorfrom problem_historyResult
  22. 22. 6. Extra Sorgular a. Genel Bakış view oluşturmaQueryCREATE OR REPLACE VIEW genel_bakisASSelect PROBLEM_HISTORY.PROBLEM_ID, PROBLEM_HISTORY.PROBLEM_HISTORY_ID, REF_PRIORITY_LEVELS.PRIORITY_LEVEL_DESCRIPTION, REF_PROBLEM_STATUS_CODE.PROBLEM_STATUS_DESCRIPTION, SUPPORT_STAFF.STAFF_NAME, PROBLEM_HISTORY.FIX_DATETIME, PROBLEM_HISTORY.PROBLEM_HISTORY_DESCRIPTION, EQUIPMENT.EQUIPMENT_NAME, USERS.USER_FIRST_NAME || || USERS.USER_LAST_NAME as KullanıcıFrom PROBLEM_HISTORY Inner Join REF_PROBLEM_STATUS_CODE On PROBLEM_HISTORY.PROBLEM_STATUS_CODE = REF_PROBLEM_STATUS_CODE.PROBLEM_STATUS_CODE Inner Join REF_PRIORITY_LEVELS On PROBLEM_HISTORY.PRIORITY_LEVEL_CODE = REF_PRIORITY_LEVELS.PROBLEM_LEVEL_CODE Inner Join SUPPORT_STAFF On PROBLEM_HISTORY.ASSIGNED_STAFF_ID = SUPPORT_STAFF.STAFF_ID Inner Join PROBLEMS On PROBLEM_HISTORY.PROBLEM_ID = PROBLEMS.PROBLEM_ID Inner Join EQUIPMENT On PROBLEMS.EQUIPMENT_ID = EQUIPMENT.EQUIPMENT_ID Inner Join USERS On PROBLEMS.USER_ID = USERS.USER_IDGroup By PROBLEM_HISTORY.PROBLEM_ID, PROBLEM_HISTORY.PROBLEM_HISTORY_ID, REF_PRIORITY_LEVELS.PRIORITY_LEVEL_DESCRIPTION, REF_PROBLEM_STATUS_CODE.PROBLEM_STATUS_DESCRIPTION, SUPPORT_STAFF.STAFF_NAME, PROBLEM_HISTORY.FIX_DATETIME, PROBLEM_HISTORY.PROBLEM_HISTORY_DESCRIPTION, EQUIPMENT.EQUIPMENT_NAME, USERS.USER_FIRST_NAME, USERS.USER_LAST_NAMEOrder By PROBLEM_HISTORY.PROBLEM_IDResult
  23. 23. b. Index OluşturmaQueryCREATE INDEX problem__id_index ON problem_history(problem_id);ResultIndex created. c. Sequence OluşturmaQueryCREATE SEQUENCE EQUIPMENT_IDINCREMENT BY 1ResultSequence created. d. Select ile yedek almakQueryselect * into problems_backup from problemsResult 7. Sonuçlar Görev Beklenen Yapılantable oluşturma 6-7 tablo 13 tabloSelect sorgusu 10 12Update/delete sorgusu 10 10İndex oluşturma 0 1View oluşturma 0 1Sequence oluşturma 0 1

×