1 / 35

بسم الله الرحمن الرحيم

بسم الله الرحمن الرحيم. Lecture( 6 ). Data Modeling Using the Entity-Relationship (ER) Model. درجة نوع العلاقة Degree) (Relationship type. هي عدد الـ types Entity المشاركة في نوع العلاقة. (Number of participant Entity type into relationship type) مثال : درجة نوع العلاقة 2 = works – for.

ekrupa
Télécharger la présentation

بسم الله الرحمن الرحيم

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. بسم الله الرحمن الرحيم Lecture( 6) Data Modeling Using the Entity-Relationship (ER) Model

  2. درجة نوع العلاقةDegree)(Relationship type • هي عدد الـ typesEntity المشاركة في نوع العلاقة. • (Number of participant Entity type intorelationship type) • مثال : درجة نوع العلاقة 2 = works – for

  3. نوع العلاقة من الدرجة الاولي : (تسمي بـ (Recursive relationship type) والعلاقة في هذا النوع تكون بين كائنات نفس الـ Entity type المشارك في نوع العلاقة. • مثال لعلاقة من الدرجة الاولي:- R .T: Supervision • كل موظف له موظف آخر يشرف علية او (يرأسه) ولذا نجد أن ال Employee E.T هي ال E .T الوحيدة المشاركة في العلاقة Supper vision

  4. r1 e1 r2 e2 e3 • e1 supervisor of e2 • e2 supervised by e1 • (all participating entity In R.T belong to only one E.T)

  5. نوع العلاقة من الدرجةالثالثة :-( (Ternary • Number of participate Entity – types In to R.T = 3

  6. مثال father parent child f1 r1 c1 mother m1

  7. انواع العلاقات من الدرجة الثانية( (Binary Relationship types: من اشهر انوع العلاقات (لذا تطبيق معظم قيود العلاقات يتم في العلاقات الثنائية)

  8. قيود انواع العلاقات (Relationship types Constraints ( • من العالم الحقيقي نجد ان معظم انواع العلاقات لها بعض القيود او الشروط . فمثلا نجد في المثال (company) ان كل موظف يجب ان يعمل في قسم واحد فقط وهذا يعتبر شرط في نوع العلاقة بين الموظف والقسم . • وهنالك نوعين من القيود يمكن تطبيقها علي ال R.Ts :- 1- Cardinality Ratio Constraints. 2- Participation Constraints • وهذان القيدان يعرفان ب structural constraints of relationship types

  9. Cont. 1-cardinality ratio constraints:- • ويتم تحديد ال ratioCardinality للعلاقة الثنائية بتحديد عدد ال (relationship Instances) والتي يشارك فيها (participant entity ). • (Specifies the relationship type instances that an entity can participate in)

  10. Department Works-for N Employee 1 • مثال: العلاقة works – for بين Department : Employee • Cardinality ratio = 1: N (N zero or more) One: Many ويوضح ذلك في E .R diagram كالاتي :

  11. University Student Teach-on N 1 Cont. • Possible cardinality ratios for binary R.T s: • 1: N, N: 1, 1: 1, M: N • One :Many , Many : One , One :One, Many : Many • مثال لN:1 :

  12. Department Employee Manages 1 Cont. • مثال : نوع العلاقة one : one 1

  13. Project Employee Works-for M N Cont. • مثال: لنوع علاقة Many : Many

  14. 2. Participation Constraints: (Existence Dependencies): • وهي لتحديد ما اذا كان وجود الكائن entity يعتمد علي علاقة تربطه بكائن اخر عبر نوع العلاقة (R.T) • هنالك نوعين ل (Participation Constraints) 1. Total Participation. 2. partial Participation.

  15. مثال ل :Total Participation اذا افترضنا ان قانون الشركة ينص علي ان أي موظف يجب ان يعمل في قسم معين إذاً ال Employee لا يمكن ان يكون موجود الا اذا كان مشارك في ال(works-for instances) • (the participation of employee in works-for R.T is total participation).

  16. Department Employee Works-for N 1 • كل الكائنات في Employee مشاركة في ال instances works – for ,يوضح ذلك في ال E.R diagram (بخطين) كالآتي:

  17. employee Manages Department e1 e2 e3 e4 r1 r2 r3 . . d1 d2 d3 . . • مثال : ل partial participate :- • نجد ان كل قسم في الشركة له رئيس (manager) ولكن ليس لكل الموظفين رؤساء اقسام (جزء من الموظفين) فاذاً • ( the participation of employee entity type n manages R.T is partial participation)

  18. No of hours Project Employee Works-on M N صفات انواع العلاقات attributes for relationshiptypes) ) • يمكن ان يكون لإنواع العلاقات صفات مثل ال (Entity types) • امثلة :- الصفه (no of hours) عدد الساعات الاسبوعية للموظف فى المشروع (project) يمكن ان تكون صفة لنوع العلاقة (works- on ) بين (employee and project) :- وتوضح فى E_R diagram كالآتى:

  19. Cont. • الصفة تاريخ تعيين المدير للقسم(start date ) يمكن ان يكون صفة للعلاقة (manages) بين (employee and department) .

  20. cont • اذا كان لنوع العلاقة صفة وcardinality ratio=1:1 ,فيمكن ان نتبع صفة العلاقة لأى واحد من ال entity types المشاركة فى نوع العلاقة. • فمثلاً الصفة تاريخ تعيين المدير للقسم يمكن ان تكون صفة ل department او صفة ل employee. • واذا ال cardinality ratio= 1:N او N:1 • فصفات نوع العلاقة تتبع ل entity type في الجانبN من العلاقة . • مثال : أذا كان لدينا مثلا صفة تاريخ تعيين الموظف في العلاقة works – for بينEmployee:Department)) , وN بجانب ال employee E.T فلذا يجب ان تتبع صفة تاريخ التعيين ل employee E.T.

  21. Cont. • اذا كانت =M:N Cardinality ratio • مثال : عدد الساعات الاسبوعية للموظف في العمل في المشروع تظل صفة لنوع العلاقة works – for بين ال employee & project.

  22. انواع الكائنات الضعيفة Weak entity types) • هي entity types ليست لها صفة او صفات ثمثل صفة المفتاح. • الكائنات التي تنتمى لل weak entity type لا تميز الا بعلاقتها مع كائنات اخرى تنتمي ل entity type اخر (owner or parent) وال weak E.Ts يطلق عليها (child E.Ts). • Child entity types participation is total participation in the relation – type between) child) weak entity type and parent entity type . R.T is called (Identifying R.T) • A weak entity has a partial key, which is the set of attributes that can uniquely identify weak entities that are related to the same owner entity.

  23. In E-R digram: Identifying relationship type Partial key Weak entity type

  24. مثال : Dependent E.T هو الtype WEAK – Entity • لا يمكن تحديد المكفول الا عن طريق الكفيل ولا يمكن ان يكون له مفتاح (فقد يحتوي المفتاح علي صفة من الصفات ال employeeمثل رقم الموظف + اسم المكفول) • ولا يوجد مكفول ليس له كفيل . Dependent M 1 Employee Dependent of

  25. Refining the ER diagram for the company database • ER DIAGRAM – Relationship Types are: • WORKS_FOR, • MANAGES, • WORKS_ON, • CONTROLS, • SUPERVISION, • DEPENDENTS_OF. Determine participate entity types and structural constraints for each relationship type.

  26. Alternative (min, max) notation for relationship structural constraints • Specified on each participation of an entity type E in a relationship type R • Specifies that each entity e in E participates in at least min and at most max relationship instances in R • Default(no constraint): min=0, max=n (signifying no limit) • Must have minmax, min0, max 1 • Derived from the knowledge of mini-world constraints • Examples: • A department has exactly one manager and an employee can manage at most one department. • Specify (0,1) for participation of EMPLOYEE in MANAGES • Specify (1,1) for participation of DEPARTMENT in MANAGES • An employee can work for exactly one department but a department can have any number of employees. • Specify (1,1) for participation of EMPLOYEE in WORKS_FOR • Specify (0,n) for participation of DEPARTMENT in WORKS_FOR

  27. The (min,max) notation for relationship constraints Read the min,max numbers next to the entity type and looking away from the entity type

  28. COMPANY ER Schema Diagram using (min, max) notation

  29. Summary of notation for ER diagrams

  30. Some of the Currently Available Automated Database Design Tools

  31. Read section 3.9

  32. Please Be attention!!!!!!! Additional lecture on Thursday (2-4)

  33. Good bye chapter THREE

  34. Quiz (2) • ارسم الـ Diagram ER للمتطلبات ادناه وهي تمثل قاعدة بيانات للافلام في السودان. • الفيلم ( Movie ) يميز باسمه وتاريخ عرضه وله مدة عرض معينة وله شركة قامت بانتاجه وله نوعية معينة ( دراما ، كوميديا ...) . • أي فيلم له عدد من المخرجين وعدد من الممثلين وله علي الاكثر إثنين من الممثلين يقومون بالدور الرئيسي في الفيلم. • الممثل ( Actor ) يمكن ان يميز باسمه وتاريخ ميلاده ويمكن ان يمثل في اكثر من فيلم وأي ممثل يجب ان يكون له دور في فيلم واحد علي الاقل وهذا الدور اما ان يكون دور عادي ( تمثيل ) او دور رئيسي. • المخرج أيضاً يميز بأسمه ويسجل تاريخ ميلاده ويجب ان يخرج فيلم واحد علي الاقل . يمكن للمخرج ايضاً أن يكون ممثلاً في أي فيلم او الافلام التي قام بإخراجها. • الشركات التي تقوم بالانتاج لها إسم وعنوان ولا يمكن لشركتين ان تحملان نفس الاسم ويمكن ان يكون للشركة اكثر من موقع داخل وخارج السودان.

More Related