Tuesday, March 6, 2018

ลองแปลง ER Diagram เป็น Relational Mapp (Week 7)

จากที่อาจารย์ให้ลองแปลง ER Diagram เป็น Relational Mapping
ข้อแรก เป็นการนำ ER Diagram จากสัปดาห์ที่ 6 มาแปลงเป็น Relational Mapping


Step 1 Mapping of Regular Entity Types
ส่วน Purchase Order

ส่วน Customer

ส่วน Line Item

Step 2 Mapping of Weak Entity Types : เนื่องจากไม่มี Weak Entity เลยไม่ต้องทำในส่วนนี้
Step 3 Mapping of Binary 1:1 Relationship Types : เนื่องจากไม่มีความสัมพันธ์แบบ 1:1 เลยไม่ต้องทำในส่วนนี้
Step 4: Mapping of Binary 1:N Relationship Types
เพิ่ม cus_num ใน Purchase Order

เพิ่ม po_numใน Line Item

เพิ่ม si_numใน Line Item

Step 5: Mapping of Binary M:N Relationship Types : เนื่องจากไม่มีความสัมพันธ์แบบ M:N เลยไม่ต้องทำในส่วนนี้
Step 6: Mapping of Multivalued Attributes
สร้างตารางของ Phone แยกออกมาเชื่อมกับ Customer
Step 7 : Mapping of N-ary Relationship Types : เนื่องจากไม่มีความสัมพันธ์แบบ N-ary เลยไม่ต้องทำ

จนสุดท้ายได้ Relational Mapping ตามนีี้
Relational Mapping ของข้อหนึ่ง


ข้อสอง เป็นการหาโจทย์มาทำ ER Diagram และทำ Relational Mapping
โดยนำโจทย์มาจากหนังสือ Fundamentals of Database Systems ใน Exercise ข้อ 7.22

โจทย์ 
A database is being constructed to keep track of the teams and games of a sports league. A team has a number of players, not all of whom participate in each game. It is desired to keep track of the players participating in each game for each team, the positions they played in that game, and the result of the game. Design an ER schema diagram for this application, stating any assumptions you make. Choose your favorite sport (e.g., soccer, baseball, football).

แปลไทย
จงสร้าง ER Diagram ที่เกี่ยวกับทีมและการแข่งขันในลีก
  • เก็บข้อมูลเกี่ยวกับทีม
  • เก็บข้อมูลของนักกีฬาที่มีส่วนร่วมในการแข่งขันของทีมนั้นๆ
  • เก็บตำแหน่งของผู้เล่นคนนั้น
  • เก็บผลการแข่งขัน
ER Diagram

จากนั้นทำ 7 Step
Step 1 Mapping of Regular Entity Types
ส่วน team

ส่วน competition

ส่วน player

Step 2 Mapping of Weak Entity Types : เนื่องจากไม่มี Weak Entity เลยไม่ต้องทำในส่วนนี้
Step 3 Mapping of Binary 1:1 Relationship Types
เพิ่ม home_team, away_team ใน competition

Step 4: Mapping of Binary 1:N Relationship Types
เพิ่ม id_team ใน player

Step 5: Mapping of Binary M:N Relationship Types : เนื่องจากไม่มีความสัมพันธ์แบบ M:N เลยไม่ต้องทำในส่วนนี้
Step 6: Mapping of Multivalued Attributes : เนื่องจากไม่มีMultivalued Attributes เลยไม่ต้องทำในส่วนนี้
Step 7 : Mapping of N-ary Relationship Types : เนื่องจากไม่มีความสัมพันธ์แบบ N-ary เลยไม่ต้องทำ

จนสุดท้ายได้ Relational Mapping ตามนีี้
Relation Mapping ข้อสอง
Project ที่ทำ คือ E-Sport Database เพื่อเก็บข้อมูล ซึ่งสามารถนำข้อมูลจากข้อสองมาใช้ต่อเนื่องได้


ปัญหาที่พบ
  • มีสอบวิชา AI เลยไม่มีเวลาทำ แก้ปัญหาโดยการใช้เวลาหลังสอบเสร็จทำเลย
  • อากาศเปลี่ยนแปลง ทำให้ไม่สบาย แก้ปัญหาโดยการรักษาสุขภาพ พกร่มด้วยนะครับ
ลิ้งก์ที่เกี่ยวข้อง

No comments:

Post a Comment

SQL injection (Week 16)

SQL Injection ในบางครั้งนักพัฒนาใช้ method ‘+’ (concat) กับ String ที่เป็นคำสั่ง SQL เพื่อ query ข้อมูลที่ user ต้องการ ซึ่งทำให้เกิดช่...