Version 76 (modified by 3 months ago) ( diff ) | ,
---|
A) Oпределување на важечките функциски зависности
Тргнуваме од список во кој сите атрибути имаат различни имиња. За таа цел атрибутите кои што имаат исти имиња ги преименувавме. Во продолжение е списокот на атрибути кои што се преименувани.
*id (Кај ентитетот Users) = users_id *id (Кај ентитетот Pet_Cares) = pet_cares_id *id (Kaj ентитетот Blog_Post_For_Consultation) = blog_post_for_consultation_id *id (Kaj ентитетот Blog_Post_Answers) = blog_post_answers_id *id (Kaj ентитетот Jobs) = jobs_id *id (Kaj ентитетот Vet_Centers) = vet_centers_id *id (Kaj ентитетот Cities) = cities_id *id (Kaj ентитетот Roles) = roles_id *id (Kaj ентитетот Reports) = reports_id *id (Kaj ентитетот Pet_Status) = pet_status_id *id (Kaj ентитетот Therapy) = therapy_id *id (Kaj ентитетот Diagnostics) = diagnostics_id *id (Kaj ентитетот Medecines) = medecines_id *id (Kaj ентитетот Manufacturers) = manufacturers_id *id (Kaj ентитетот Pets) = pets_id *id (Kaj ентитетот Pet_Galery) = pet_galery_id *id (Kaj ентитетот Orders) = orders_id *id (Kaj ентитетот Products) = products_id *id (Kaj ентитетот Type_Of_Pets) = type_of_pets_id *id (Kaj ентитетот Breeds) = breeds_id *title (Kaj ентитетот Blog_Post_For_Consultations) = blog_post_title *description (Kaj ентитетот Blog_Post_For_Consultations) = blog_post_description *description (Kaj ентитетот Jobs) = jobs_description *description (Kaj ентитетот Vet_Centers) = vet_centers_description *name (Kaj ентитетот Cities) = cities_name *description (Kaj ентитетот Reports) = reports_description *type (Kaj ентитетот Pet_Status) = pet_status_type *description (Kaj ентитетот Therapy) = therapy_description *description (Kaj ентитетот Diagnostics) = diagnostics_description *name (Kaj ентитетот Medecines) = medecines_name *description (Kaj ентитетот Medecines) = medecines_description *name (Kaj ентитетот Manufacturers) = manufacturers_name *description (Kaj ентитетот Manufacturers) = manufacturers_description *name (Kaj ентитетот Pets) = pets_name *description (Kaj ентитетот Pets) = pets_description *name (Kaj ентитетот Products) = products_name *description (Kaj ентитетот Products) = products_description *description (Kaj ентитетот Type_Of_Pets) = type_of_pets_description *name (Kaj ентитетот Breeds) = breeds_name
Функциски зависности
R(jobs_id, jobs_description, predistedSalery, pet_cares_id, title, description, start_date, dateEnding,vet_centers_id, name, address, vet_centers_description, workingHours, latitude, longitude,roles_id, type, users_id, first_name, last_name, phoneNumber, email, password, blog_post_for_consultation_id, blog_post_title, blog_post_description, dateAsked, blog_post_answers_id, parent_id, reply, date_answers, cities_id, cities_name, reports_id, reports_description, pets_id, pet_status_id, node, pet_status_type, therapy_id, appoitmentDate, therapy_description, diagnostics_id, diagnostics_description, medecines_id, manufacturers_name, medecines_description, manufacturers_id, city, state, manufacturers_name, manufacturers_description, pets_name, color, dateOfBirthday, pets_description, type_of_pets_id, pet_galery_id, image, orders_id, products_id, products_name, products_description, category, dateAdded,isActive, price, available_quantity, quantity, breeds_id, breeds_name, kind_of_pet, type_of_pets_description)
- jobs_id -> jobs_description, predistedSalery (Секоја работна позиција си има опис и предвидена плата).
- pet_cares_id ->title, description, start_date, dateEnding (Секоја услуга си има име, опис, датум на започнување и датум на завршување).
- vet_centers_id-> name, address, vet_centers_description, workingHours, latitude, longitude (Секој вет. центар си има име, адреса, работни часови, координати ( гео. должина и ширина).
- roles_id->type (Секоја улога си има свој тип).
- users_id -> first_name, last_name, phoneNumber, email, password, roles_id (Секој корисник има име, презиме, тел.број, емаил и пасворд.Секој корисник може да има само една улога: стандарден корисник, менаџер, вработен или админ. Според улогата корисникот добива одредени привилегии).
- blog_post_for_consultation_id -> blog_post_title, blog_post_description, dateAsked, users_id (Секое поставено прашање/побарана консултција има наслов, опис, и датум на поставување. Секој побаран совет/прашање е напишен од одреден корисник).
- blog_post_answers_id ->parent_id, reply, date_answers, blog_post_for_consultation_id, users_id (Секој одговор е даден врз основа на поставено прашање, има содржина и датум кога е одговорено. Секој одговор е поврзан со едно прашање за консултација и е даден од еден корисник).
- cities_id-> cities_name (Секој град си има име).
- reports_id-> reports_description, pets_id, (Секој извештај има опис. Секој извештај припаѓа на едно милениче)
- reports_id , pets_id→ users_id (Секој извештај за одредено милениче е напишан од еден корисник-доктор).
- pet_status_id->node, pet_status_type (Секој статус има забелешка и тип).
- therapy_id->appoitmentDate, therapy_description (Секоја терапија има датум на започнување и опис).
- diagnostics_id-> diagnostics_description (Секоја дијагноза има опис)
- medecines_id-> medecines_name, medecines_description (Секој лек има име, и упатство)
- manufacturers_id->city, state, manufacturers_name, manufacturers_description (Секој производител на лекот има град, држава, име и опис).
- pets_id-> pets_name, color, dateOfBirthday, pets_description, type_of_pets_id, users_id (Секое милениче има име, боја, датум на раѓање и опис. Секое милениче припаѓа на еден вид. Секое милениче има само еден сопственик, во нашата база не е возможно едно милениче да има повеќе сопственици. Кога се врши микрочипирање се запишуваат податоци само од еден сопственик).
- pet_galery_id->image, pets_id (Секоја слика во галеријата е поврзана само со едно милениче, во нашиот проект имаме замислено на една слика да има само едно милениче за поголема прегледност на идните вдомувачи).
- orders_id → userid (Секоја нарачка е направена од еден корисник).
- products_id-> products_name, products_description, category, dateAdded, isActive, price, available_quantity (Секој продукт има име, опис, категорија, датум кога е додаден во системот, дали е достапен, цена и достапна количина).
- products_id, orders_id → quantity (Секој продукт кој што се наоѓа во нарачката има одредена количина).
- breeds_id-> breeds_name, type_of_pets_id (Секоја раса си има име. Секоја раса припаѓа на еден вид на милениче, Пр.расата Scottish Fold припага само на видот маче не припага и на видот куче итн).
- type_of_pets_id->kind_of_pet, type_of_pets_description (Секој вид на милениче има име и опис).
- medecines_id → manufacturers_id (Во нашиот проект претпоставуваме дека секој лек е произведен од само еден произведувач).
- vet_centers_id, pets_id → pet_status_id (Секое милениче во еден ветеринарен центар има само еден активен статус во даден момент. Кога статусот се менува, се брише претходниот и се запишува нов.)
Определување на кандидат клучеви
Од лева страна се наоѓаат следниве атрибути: jobs_id, pet_cares_id, vet_centers_id, blog_post_answers_id, cities_id, reports_id, therapy_id, diagnostics_id, medecines_id, manufacturers_id, pet_galery_id, products_id, breeds_id. Од десна страна се наоѓаат следниве атрибути: jobs_description, predistedSalery, title, description, start_date, dateEnding, name, address, vet_centers_description, workingHours, latitude, longitude, type, first_name, last_name, phoneNumber, email, password, blog_post_title, blog_post_description, dateAsked, parent_id, reply, date_answers, cities_name, reports_description, node, pet_status_type, appoitmentDate, therapy_description, diagnostics_description, medecines_name, medecines_description, city, state, manufacturers_name, manufacturers_description, pets_name, color, dateOfBirthday, pets_description, image, products_name, products_description, category, dateAdded, isActive, price, available_quantity, quantity, breeds_name, kind_of_pet, type_of_pets_description. Од десна и лева страна се наоѓаат следниве атрибути: roles_id, users_id, blog_post_for_consultation_id, pets_id, type_of_pets_id, pet_status_id. Започнуваме од тривијален суперклуч па постепено отстрануваме атрибути {jobs_id, jobs_description, predistedSalery, pet_cares_id, title, description, start_date, dateEnding,vet_centers_id, name, address, vet_centers_description, workingHours, latitude, longitude, roles_id, type, users_id, first_name, last_name, phoneNumber, email, password, blog_post_for_consultation_id, blog_post_title, blog_post_description, dateAsked, blog_post_answers_id, parent_id, reply, date_answers, cities_id, cities_name, reports_id, reports_description, pets_id, pet_status_id, node, pet_status_type, therapy_id, appoitmentDate, therapy_description, diagnostics_id, diagnostics_description, medecines_id, manufacturers_name, medecines_description, manufacturers_id, city, state, manufacturers_name, manufacturers_description, pets_name, color, dateOfBirthday, pets_description, type_of_pets_id, pet_galery_id, image, orders_id, products_id, products_name, products_description, category, dateAdded,isActive, price, available_quantity, quantity, breeds_id, breeds_name, kind_of_pet, type_of_pets_description} += {jobs_id, jobs_description, predistedSalery, pet_cares_id, title, description, start_date, dateEnding,vet_centers_id, name, address, vet_centers_description, workingHours, latitude, longitude,roles_id, type, users_id, first_name, last_name, phoneNumber, email, password, blog_post_for_consultation_id, blog_post_title, blog_post_description, dateAsked, blog_post_answers_id, parent_id, reply, date_answers, cities_id, cities_name, reports_id, reports_description, pets_id, pet_status_id, node, pet_status_type, therapy_id, appoitmentDate, therapy_description, diagnostics_id, diagnostics_description, medecines_id, manufacturers_name, medecines_description, manufacturers_id, city, state, manufacturers_name, manufacturers_description, pets_name, color, dateOfBirthday, pets_description, type_of_pets_id, pet_galery_id, image, orders_id, products_id, products_name, products_description, category, dateAdded,isActive, price, available_quantity, quantity, breeds_id, breeds_name, kind_of_pet, type_of_pets_description} Атрибутите кои што се наоѓаат само од десна страна може да ги отстраниме. Со тоа ги острануваме следниве атрибути: jobs_description, predistedSalery, title, description, start_date, dateEnding, name, address, vet_centers_description, workingHours, latitude, longitude, type, first_name, last_name, phoneNumber, email, password, blog_post_title, blog_post_description, dateAsked, parent_id, reply, date_answers, cities_name, reports_description, node, pet_status_type, appoitmentDate, therapy_description, diagnostics_description, medecines_name, medecines_description, city, state, manufacturers_name, manufacturers_description, pets_name, color, dateOfBirthday, pets_description, image, products_name, products_description, category, dateAdded, isActive, price, available_quantity, quantity, breeds_name, kind_of_pet, type_of_pets_description. {jobs_id, pet_cares_id, title, description, start_date,vet_centers_id, roles_id, users_id, blog_post_for_consultation_id, blog_post_answers_id, cities_id, reports_id, pets_id, pet_status_id, therapy_id, diagnostics_id, medecines_id, manufacturers_id, type_of_pets_id, pet_galery_id, orders_id, products_id, products_name, products_description, category, dateAdded,isActive, breeds_id, kind_of_pet} += {jobs_id, jobs_description, predistedSalery, pet_cares_id, title, description, start_date, dateEnding,vet_centers_id, name, address, vet_centers_description, workingHours, latitude, longitude,roles_id, type, users_id, first_name, last_name, phoneNumber, email, password, blog_post_for_consultation_id, blog_post_title, blog_post_description, dateAsked, blog_post_answers_id, parent_id, reply, date_answers, cities_id, cities_name, reports_id, reports_description, pets_id, pet_status_id, node, pet_status_type, therapy_id, appoitmentDate, therapy_description, diagnostics_id, diagnostics_description, medecines_id, manufacturers_name, medecines_description, manufacturers_id, city, state, manufacturers_name, manufacturers_description, pets_name, color, dateOfBirthday, pets_description, type_of_pets_id, pet_galery_id, image, orders_id, products_id, products_name, products_description, category, dateAdded,isActive, price, available_quantity, quantity, breeds_id, breeds_name, kind_of_pet, type_of_pets_description} Можеме да го отстраниме и pets_id бидејќи се добива преку pet_galery_id. Можеме да го отстраниме и pet_status_id бидејќи се добива преку vet_centers_id, pets_id. Можеме да го отстраниме и type_of_pets_id бидејќи се добива преку breeds_id. Можеме да го отстраниме и blog_post_for_consultation_id бидејќи се добова преку blog_post_answers_id. Можеме да го отстраниме и users_id бидејќи се добива преку orders_id. Можеме да го отстраниме и roles_id бидејќи се добива преку users_id. За кандидат клуч добивме: {jobs_id, pet_cares_id, blog_post_answers_id, cities_id, reports_id, therapy_id, medecines_id, pet_galery_id, orders_id, products_id, breeds_id, vet_centers_id}. Ниту еден од атрибутите го нема од десна страна во ф.з па ова ни е единствен кандидат клуч, го прогласуваме за примарен клуч. {jobs_id, pet_cares_id, blog_post_answers_id, cities_id, reports_id, therapy_id, medecines_id, pet_galery_id, orders_id, products_id, breeds_id, vet_centers_id} += {jobs_id, jobs_description, predistedSalery, pet_cares_id, title, description, start_date, dateEnding,vet_centers_id, name, address, vet_centers_description, workingHours, latitude, longitude,roles_id, type, users_id, first_name, last_name, phoneNumber, email, password, blog_post_for_consultation_id, blog_post_title, blog_post_description, dateAsked, blog_post_answers_id, parent_id, reply, date_answers, cities_id, cities_name, reports_id, reports_description, pets_id, pet_status_id, node, pet_status_type, therapy_id, appoitmentDate, therapy_description, diagnostics_id, diagnostics_description, medecines_id, manufacturers_name, medecines_description, manufacturers_id, city, state, manufacturers_name, manufacturers_description, pets_name, color, dateOfBirthday, pets_description, type_of_pets_id, pet_galery_id, image, orders_id, products_id, products_name, products_description, category, dateAdded,isActive, price, available_quantity, quantity, breeds_id, breeds_name, kind_of_pet, type_of_pets_description}
Декомпозиција
jobs_id -> jobs_description, predistedSalery
pet_cares_id ->title, description, start_date, dateEnding
vet_centers_id-> name, address, vet_centers_description, workingHours, latitude, longitude
roles_id->type
users_id -> first_name, last_name, phoneNumber, email, password, roles_id
blog_post_for_consultation_id -> blog_post_title, blog_post_description, dateAsked, users_id
blog_post_answers_id ->parent_id, reply, date_answers, blog_post_for_consultation_id, users_id
cities_id-> cities_name
reports_id-> reports_description, pets_id
reports_id , pets_id→ users_id
pet_status_id->node, pet_status_type
therapy_id->appoitmentDate, therapy_description
diagnostics_id-> diagnostics_description
medecines_id-> medecines_name, medecines_description
pets_id-> pets_name, color, dateOfBirthday, pets_description, type_of_pets_id, users_id
pet_galery_id->image, pets_id
orders_id → userid
products_id-> products_name, products_description, category, dateAdded, isActive, price, available_quantity
products_id, orders_id → quantity
breeds_id-> breeds_name, type_of_pets_id
type_of_pets_id->kind_of_pet, type_of_pets_description
medecines_id → manufacturers_id
vet_centers_id, pets_id → pet_status_id
Во вака дефинираната релација нема повеќекратни зависности и атрибути и нема вгнездени релации, па оттука следува дека задоволува 1NF.
jobs_id → jobs_description, predistedSalery - Нарушува 2NF бидејќи има парцијална зависност. jobs_id е подмножество на к.к а десно имаме непримарни атрибути.
jobs_id +={ jobs_id, jobs_description, predistedSalery }
R1 (jobs_id, jobs_description, predistedSalery) клуч jobs_id, BCNF.
Со наоѓање на сите затварачи
F1 = { jobs_id → jobs_description, predistedSalery }
R2 (jobs_id, pet_cares_id, title, description, start_date,
dateEnding,vet_centers_id, name, address, vet_centers_description, workingHours,
latitude, longitude,roles_id, type, users_id, first_name, last_name,
phoneNumber, email, password, blog_post_for_consultation_id, blog_post_title,
blog_post_description, dateAsked, blog_post_answers_id, parent_id, reply, date_answers,
cities_id, cities_name, reports_id, reports_description, pets_id, pet_status_id, node,
pet_status_type, therapy_id, appoitmentDate, therapy_description, diagnostics_id,
diagnostics_description, medecines_id, manufacturers_name, medecines_description,
manufacturers_id, city, state, manufacturers_name, manufacturers_description, pets_name,
color, dateOfBirthday, pets_description, type_of_pets_id, pet_galery_id, image, orders_id,
products_id, products_name, products_description, category, dateAdded,isActive, price,
available_quantity, quantity, breeds_id, breeds_name, kind_of_pet, type_of_pets_description
)
Со наоѓање на сите затварачи
F2 = (pet_cares_id ->title, description, start_date, dateEnding
vet_centers_id-> name, address, vet_centers_description, workingHours, latitude, longitude
roles_id->type
users_id -> first_name, last_name, phoneNumber, email, password, roles_id
blog_post_for_consultation_id -> blog_post_title, blog_post_description, dateAsked, users_id
blog_post_answers_id ->parent_id, reply, date_answers, blog_post_for_consultation_id, users_id
cities_id-> cities_name
reports_id-> reports_description, pets_id
reports_id , pets_id→ users_id
pet_status_id->node, pet_status_type
therapy_id->appoitmentDate, therapy_description
diagnostics_id-> diagnostics_description
medecines_id-> medecines_name, medecines_description
pets_id-> pets_name, color, dateOfBirthday, pets_description, type_of_pets_id, users_id
pet_galery_id->image, pets_id
orders_id → userid
products_id-> products_name, products_description, category, dateAdded, isActive, price, available_quantity
products_id, orders_id → quantity
breeds_id-> breeds_name, type_of_pets_id
type_of_pets_id->kind_of_pet, type_of_pets_description
medecines_id → manufacturers_id
vet_centers_id, pets_id → pet_status_id)
Клуч (pet_cares_id, blog_post_answers_id, cities_id, reports_id, therapy_id, medecines_id,
pet_galery_id, orders_id, products_id, breeds_id)
R1 n R2 = jobs_id, клуч за R1 што значи нема губење на податоци.
R2 не е во 2NF поради pet_cares_id ->title, description, start_date, dateEnding
pet_cares_id +={ pet_cares_id , title, description, start_date, dateEnding}
R21 (pet_cares_id , title, description, start_date, dateEnding) клуч pet_cares_id, BCNF
F21 { pet_cares_id ->title, description, start_date, dateEnding}
R22 (pet_cares_id, vet_centers_id, name, address, vet_centers_description, workingHours,
latitude, longitude,roles_id, type, users_id, first_name, last_name,
phoneNumber, email, password, blog_post_for_consultation_id, blog_post_title,
blog_post_description, dateAsked, blog_post_answers_id, parent_id, reply, date_answers,
cities_id, cities_name, reports_id, reports_description, pets_id, pet_status_id, node,
pet_status_type, therapy_id, appoitmentDate, therapy_description, diagnostics_id,
diagnostics_description, medecines_id, manufacturers_name, medecines_description,
manufacturers_id, city, state, manufacturers_name, manufacturers_description, pets_name,
color, dateOfBirthday, pets_description, type_of_pets_id, pet_galery_id, image, orders_id,
products_id, products_name, products_description, category, dateAdded,isActive, price,
available_quantity, quantity, breeds_id, breeds_name, kind_of_pet, type_of_pets_description
)
F22 = ( vet_centers_id-> name, address, vet_centers_description, workingHours, latitude, longitude
roles_id->type
users_id -> first_name, last_name, phoneNumber, email, password, roles_id
blog_post_for_consultation_id -> blog_post_title, blog_post_description, dateAsked, users_id
blog_post_answers_id ->parent_id, reply, date_answers, blog_post_for_consultation_id, users_id
cities_id-> cities_name
reports_id-> reports_description, pets_id
reports_id , pets_id→ users_id
pet_status_id->node, pet_status_type
therapy_id->appoitmentDate, therapy_description
diagnostics_id-> diagnostics_description
medecines_id-> medecines_name, medecines_description
pets_id-> pets_name, color, dateOfBirthday, pets_description, type_of_pets_id, users_id
pet_galery_id->image, pets_id
orders_id → userid
products_id-> products_name, products_description, category, dateAdded, isActive, price, available_quantity
products_id, orders_id → quantity
breeds_id-> breeds_name, type_of_pets_id
type_of_pets_id->kind_of_pet, type_of_pets_description
medecines_id → manufacturers_id
vet_centers_id, pets_id → pet_status_id)
R22 n R21 = pet_cares_id, клуч за R21 => нема губење на податоци.
R22 не е во 2NF поради vet_centers_id-> name, address, vet_centers_description, workingHours, latitude, longitude
vet_centers_id +={ vet_centers_id, name, address, vet_centers_description, workingHours, latitude, longitude}
R221 (vet_centers_id, name, address, vet_centers_description, workingHours, latitude, longitude) клуч vet_centers_id, BCNF
F221 { vet_centers_id-> name, address, vet_centers_description, workingHours, latitude, longitude}
R222 (vet_centers_id,roles_id, type, users_id, first_name, last_name,
phoneNumber, email, password, blog_post_for_consultation_id, blog_post_title,
blog_post_description, dateAsked, blog_post_answers_id, parent_id, reply, date_answers,
cities_id, cities_name, reports_id, reports_description, pets_id, pet_status_id, node,
pet_status_type, therapy_id, appoitmentDate, therapy_description, diagnostics_id,
diagnostics_description, medecines_id, manufacturers_name, medecines_description,
manufacturers_id, city, state, manufacturers_name, manufacturers_description, pets_name,
color, dateOfBirthday, pets_description, type_of_pets_id, pet_galery_id, image, orders_id,
products_id, products_name, products_description, category, dateAdded,isActive, price,
available_quantity, quantity, breeds_id, breeds_name, kind_of_pet, type_of_pets_description
)
F222 = (roles_id->type
users_id -> first_name, last_name, phoneNumber, email, password, roles_id
blog_post_for_consultation_id -> blog_post_title, blog_post_description, dateAsked, users_id
blog_post_answers_id ->parent_id, reply, date_answers, blog_post_for_consultation_id, users_id
cities_id-> cities_name
reports_id-> reports_description, pets_id
reports_id , pets_id→ users_id
pet_status_id->node, pet_status_type
therapy_id->appoitmentDate, therapy_description
diagnostics_id-> diagnostics_description
medecines_id-> medecines_name, medecines_description
pets_id-> pets_name, color, dateOfBirthday, pets_description, type_of_pets_id, users_id
pet_galery_id->image, pets_id
orders_id → userid
products_id-> products_name, products_description, category, dateAdded, isActive, price, available_quantity
products_id, orders_id → quantity
breeds_id-> breeds_name, type_of_pets_id
type_of_pets_id->kind_of_pet, type_of_pets_description
medecines_id → manufacturers_id
vet_centers_id, pets_id → pet_status_id)
R222 n R221 = vet_centers_id, клуч за R221 => нема губење на податоци.
Attachments (1)
- Popraven_Dijagram_Elena.jpg (214.6 KB ) - added by 3 months ago.
Download all attachments as: .zip