1 / 39

Data Modeling Using the Entity-Relationship Model

Data Modeling Using the Entity-Relationship Model. เนื้อหา. การออกแบบฐานข้อมูล Entity-Relationship Model หลักการของอีอาร์โมเดล กรณีตัวอย่าง การทำแผนภาพอีอาร์. Entity Relationship Data Model. ER-Model describes data as Entities Attributes Relationships. Entities และ Attributes.

brosh
Download Presentation

Data Modeling Using the Entity-Relationship Model

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. Data ModelingUsingthe Entity-RelationshipModel

  2. เนื้อหา • การออกแบบฐานข้อมูล • Entity-Relationship Model • หลักการของอีอาร์โมเดล • กรณีตัวอย่าง • การทำแผนภาพอีอาร์

  3. Entity Relationship Data Model ER-Model describes data as • Entities • Attributes • Relationships

  4. Entities และ Attributes • Entityคือ วัตถุสิ่งของหรือนามธรรมที่เราสนใจ • Entityอาจเป็นออปเจกที่จับต้องได้ (object with a physical existence) เช่น person, car , house, employee • Entityอาจเป็นออปเจกเชิงหลักการ (object with a conceptual existence)เช่น job, a university course.

  5. Attributes • Attributeคือ คุณสมบัติเฉพาะที่ใช้อธิบายเอนติตี หรือ เป็นคุณสมบัติของเอนติตีแต่ละตัวนั่นเอง • ค่าของแอตตริบิว (attribute values)ที่อธิบายแต่ละเอนติตีคือข้อมูลทีถูกเก็บในฐานข้อมูลต่อไป • ตัวอย่าง • เอนติตี Employee มีคุณสมบัติดังต่อไปนี้ • ชื่อพนักงาน (Name), อายุ (Age), ที่อยู่ (address), เงินเดือน (salary)และตำแหน่งงาน(job)

  6. Attribute & Attribute Value Attribute Student Name Faculty Major ID 475020126-3 Kamonphon Science IT 465020100-0 PiyathiDa Science Comp SC. Attribute Value

  7. Attribute Type • Atomic Attribute • Composite Attributes • Single-Valued • Multi Valued • Stored Attribute • Derived Attribute

  8. Atomic Simple Atomic Attribute • Atomic Attribute คือแอตตริบิวที่ไม่สามารถแยกย่อยออกไปได้อีก • เรียกว่าAtomicหรือSimple Attributes. • ตัวอย่างเช่น Student First Name Last Name Age

  9. Composite Attribute Street Address ZipCode Tambol Province District Composite Attribute? Atomic Attribute Composite Attributes • Composite Attributes สามารถที่จะแบ่งออกเป็นส่วนของแอตตริบิวย่อย ที่มีความหมายที่เป็นอิสระต่อกันได้ Address

  10. Single-Valued VS Multi Valued Attributes • Single-Valued : แอตตริบิวที่มีค่าเพียงค่าเดียวสำหรับเอนติตีใดๆ • Multi Value Attribute: มีค่าได้หลายค่า

  11. Attribute Age Degree A : 24 Years B : 27 Years A : B.Sc. B : B.Sc, M.Sc., Dr. Eng. AttributeValue Example

  12. Stored VS Derived Attributed • Stored Attribute • Derived Attribute: คือค่าของแอตตริบิวดังกล่าวสามารถกำหนดหรือคำนวณจากแอตตริบิวอื่นๆ หรือ เอนติตีอื่นๆ ที่มีความเกี่ยวข้องกันได้

  13. Attribute Stored Attribute Age Birth Day A : 24 Years B : 40 Years A : 13 July 1980 B : 23 Dec 1964 Derived Attribute AttributeValue Example

  14. Key Attribute • KeyAttributeคือแอตตริบิว (หรือกลุ่มของแอตตริบิว) ที่ค่าของมันสามารถใช้แยกความแตกต่างของเอนติตีแต่ละตัวในเอนติตีเซตได้ หรือกล่าวได้ว่าเป็นแอตตริบิวที่ใช้เป็นตัวแทนของแต่ละเอนติตีในเอนติตีเช็ค • คุณสมบัติของคีย์แอตตริบิว • Unique • Not Null

  15. Null Value สำหรับบางกรณีเอนติตีบางตัวอาจไม่มีค่าปรากฏในบางแอตตริบิว ยกตัวอย่างเช่น Degree attributeจะปรากฏค่าเฉพาะสำหรับคนที่สำเร็จการศึกษาในระดับวิทยาลัย/มหาวิทยาลัย ในสถานการณ์ดังกล่าวค่าของ Degree attribute จะมีค่าพิเศษเรียกว่าค่า null

  16. Entity Type • Strong Entity Type • คือเอนติตีที่มีคีย์แอตตริบิวของตนเอง (Entity that do have a key attribute) • Weak Entity Type • คือเอนติตีที่ไม่มีคีย์แอตตริบิวของตนเอง • เป็นเอนติตีที่ขึ้นกับเอนติตีอื่น(Depend on other entities) • เอนติตีที่ถูกขึ้นตรงจะเรียกว่า owner entity • ความสัมพันธ์ระหว่าง Owner กับ Weak entities ถูกเรียกว่า “identifying relationship”

  17. Example • Entity • Employee • Department • Project • Dependent

  18. Entity Type, Entity Sets, Keys, Value Set • Entity typeคอลเลกชันหรือเซตของเอนติตีที่มีแอตตริบิวเหมือนกัน • แต่ละ entity type ในฐานข้อมูลจะต้องมีการกำหนดชื่อของเอนติตีและแอตตริบิวเป็นตัวแสดงคุณสมบัติ • Entity set คือคอลเลกชันของเอนติตีในขณะใดขณะหนึ่ง • Entity set ปกติใช้ชื่อเดียวกันกับเอนติ entity type.

  19. Relationshipเป็นความสัมพันธ์ระหว่างเอนติตีRelationshipเป็นความสัมพันธ์ระหว่างเอนติตี

  20. Relationship Type • Relationship type Rระหว่าง n entity types E1,E2,…,En • บอกกลุ่มความสัมพันธ์(association or relationship) ระหว่าง entities • Mathematically, • the relationship set R • คือเซตของความสัมพันธ์ ri, • โดยที่แต่ละ riสัมพันธ์กับ n individual entities (e1,e2,…, en) • และแต่ละเอนติตี ejใน riคือสมาชิกของแต่ละเอนติตีEj, 1 ≤ j ≤ n.

  21. Relationship Degree • Degreeของ relationship type คือจำนวนของเอนติตีเช็ค ที่เกิดความสัมพันธ์กัน • For example - Degreeของความสัมพันธ์ระหว่างอาจารย์และนักศึกษาจะมี ค่าเท่ากับ สอง - Degreeที่มีค่าเท่ากับสองเรียกว่า binary สาม คือ ternary ตามลำดับ

  22. Constraint on Relationship Types • Two main Type of relationship constraints • Cardinality ratio • Participation

  23. Cardinality Ratios • Cardinality ratioกำหนดค่ามากสุดของสมาชิกของความสัมพันธ์ที่เอนติตีเข้าไปมีส่วนเกี่ยวข้อง • 1 to 1 Relationship (1:1) • 1 to many relationship (1:N) • Many to Many relationship (N:M)

  24. 1:1 Relationship R1 R2 R3 R4 T1 T2 T3 T4 T5 T6 T7 D1 D2 D3 D4 Entity E2 Entity T Relationship

  25. 1:1 Relationship Head Head Head Head Apisak Pusadee Pramot Somjit Pattana Kriat Sartra CompSc Stat Physics Math Entity E2 Entity T Relationship

  26. 1 to Many Relationship R1 R2 R3 R4 E1 E2 E3 E4 E5 E6 E7 D1 D2 D3 D4 Entity D Entity E Relationship

  27. 1:1 Relationship work Work Work Work Apisak Pusadee Somjit Pramot Pattana Tasanee Jirasuk CompSc Stat Physics Math Entity E2 Entity T Relationship

  28. E1 E2 E3 E4 E5 E6 E7 J1 J2 J3 J4 Entity J Entity E Many to Many Relationship R1 R2 R3 R4 Relationship

  29. Aim Daw Dam Aun Nuu Nam F Project File&DB English Cal Subject Student Many to Many Relationship R1 R2 R3 R4 Register

  30. Participation Constraints and Existence Dependencies • Participation Constraints • เป็นการระบุว่าสมาชิกเอนติตีในเอนติตีเซ็ตขึ้นกับเอนติตีอื่นโดยผ่านทางความสัมพันธ์ • มันจะระบุจำนวนที่น้อยที่สุดของสมาชิกในเอนติตีที่มีความสัมพันธ์หรือที่เกี่ยวข้องไว้ ซึ่งเราเรียกว่าminimum cardinality constraint.

  31. Participation type • Partial participation • Total participation (existence dependency)

  32. Total participation R1 R2 R3 R4 E1 E2 E3 E4 E5 E6 E7 D1 D2 D3 D4 Entity แผนก Relationship สังกัด Entity พนักงาน

  33. E1 E2 E3 E4 E5 E6 E7 D1 D2 D3 D4 Partial participation R1 R2 R3 R4 Entity E Entity D Relationship

  34. Entity Weak Entity Relationship Symbol

  35. Weak Entity Attribute Key Attribute Composite Attribute Derived Attribute

  36. E1 E2 R E1 E2 R 1 N partial Total Cardinality Ratio

  37. ER-Diagram

  38. Another ER-Diagram

  39. UML Class diagram

More Related