วันอังคารที่ 3 เมษายน พ.ศ. 2561

Normalization


Database Normalization Examples -

Assume a video library maintains a database of movies rented out. Without any normalization, all information is stored in one table as shown below
1NF (First Normal Form) Example

2NF (Second Normal Form)

It is clear that we can't move forward to make our simple database in 2nd Normalization form unless we partition the table above

Table 1

Table 2

3NF (Third Normal Form)

To move our 2NF table into 3NF, we again need to again divide our table.

Table 1

Table 2

Table 3

We have again divided our tables and created a new table which stores Salutations. 
There are no transitive functional dependencies, and hence our table is in 3NF
In Table 3 Salutation ID is primary key, and in Table 1 Salutation ID is foreign to primary key in Table 3

Homework week11


    - What have you done/learned

Guideline 4

  • ออกแบบให้ relation schema ที่มีการ equally join (เลือกจาก attributes ที่เหมาะสม) จะทำให้ไม่เกิด spurious tuples(เกิดจากการ join โดยไม่ใช้ primary key หรือ foriegn key 
  • เลี่ยงการใช้ attributes ที่ไม่ใช่ PK หรือ FK มาใช้ join เนื่องจากการ join attributeเหล่านี้อาจทำให้เกิด spurious tuples
  • แนวทางที่ไม่เป็นทางการนี้จำเป็นต้องมีการระบุอย่างเป็นทางการมากขึ้น ใน Section 16.2(ใน text book) จะกล่าวถึงเงื่อนไขอย่างเป็นทางการที่เรียกว่า non-additive (หรือ lossless) join property ซึ่งรับประกันว่าการ join บางอย่างจะไม่ทำให้เกิด spurious tuples

Homework week8



    - What have you done/learned

          Summary of performance comparisons

GitLab Link Code
File Student.csv
File Registration.csv



Homework week7

    - What have you done/learned

Use seven-step algorithm to convert your group 
ER diagram into relations

Seven steps to converting
- Step 1: Mapping of Regular Entity Types
- Step 2: Mapping of Weak Entity Types
- Step 3: Mapping of Binary 1:1 Relationship Types
- Step 4: Mapping of Binary 1:N Relationship Types
- Step 5: Mapping of Binary M:N Relationship Types
- Step 6: Mapping of Multivalued Attributes
- Step 7: Mapping of N-array Relationship Types







Step 7: no N-array Relationship Types






Homework week6


- What have you done/learned
    Try to insert more transcript data into DBMS
ทดลองสร้างไฟล์ขนาดใหญ่เพิ่มขึ้นเรื่อยๆ ดังตาราง 
จากนั้นทำการ import เข้า MySQL โดยใช้ python (library อยู่ใน Link)
แล้วใช้การ Query แบบ ทั้งหมด ( select * )

QUERY ALL
FETCH TIME (second)
1000 rows (0.28 MB)
0.031
9202 rows (1.93 MB)
0.016
12113 rows (2.18 MB)
0.157
20058 rows (4.54 MB)
1.453
550113 rows (78.71 MB)
1.828
3,622,113 rows (487.23 MB)
9.938
5,179,927 rows (733.53 MB)
15.984
16,084,625 rows (2271.03 MB)
54.125



- Any problem/solution
     การสร้างไฟล์ ขนาดใหญ่ใช้เวลานาน

- Decision
     สร้างไฟล์ .csv จาก google spreadsheet โดยใช้การ copy



วันเสาร์ที่ 31 มีนาคม พ.ศ. 2561

Homework week5



- What have you done/learned
    Find example ER diagram from other textbooks
Textbook Name : "Database Concept 6th Edition" 


      สัญลักษณ์แสดงลักษณะเช่น Weak Entity, Multi-Value Attribute นั้น แต่ละ textbook จะวาดได้หลายแบบ แต่ความหมายที่สื่ออกมานั้นจะคล้ายคลึงกัน

- Any problem/solution
      การวาดเส้นเชื่อมระหว่างรูป Entity และ Relation โดยใช้ Google Slides นั้นเป็นไปได้ยาก เนื่องจากไม่ได้ถูกออกแบบมาเพื่อวาด Diagram
      ความสัมพันธ์แบบ Total participation หมายถึง สิ่งๆนึงต้องมีความสัมพันธ์ในอีกEntity ทั้งหมด เช่น Student อยู่ใน department

Homework week4


- What have you done/learned
Try to insert transcript data of your group members into DBMS
    ออกแบบ format ของข้อมูล transcript ใหม่
Registration มี column
  Year / Term / Student ID / Subject Code / Course Title / Credit / Grade
Subject มี column
       Subject Code / Course Title / Credit / Group
Student มี column
      Student ID / Prefix / Name / Surname / Faculty / Major

โดยให้แต่ละคนเข้ามาใส่ข้อมูลของตนเอง

      Think about impact of globalisation
Me (ต่อเรา)
ทำให้เรารับรู้ข่าวสารทั่วโลกได้ไวขึ้น ได้รู้จักคนมากมายในโลกอินเตอร์เน็ต

มีโอกาสก้าวหน้ามากขึ้น
แต่ขณะเดียวกัน ในโลกความเป็นจริงก็อาจทำให้เราอยู่แต่กับหน้าจอไม่มีการพบปะสังสรรค์กับคนอื่
Thailand (ต่อประเทศ)
มีเทคโนโลยีใหม่ๆ เข้ามาทำงานแทนคน ทำให้คนตกงาน

- Any problem/solution
    การรวมข้อมูลของทุกคนเป็นไปอย่างล่าช้า เนื่องจากเริ่มต้องแต่ละคนที format การเก็บข้อมูลที่แตกต่างกัน ก่อนที่จำลงมือใส่ข้อมูลนั้น จึงต้องมีการตกลงกันก่อน

- Decision
      เริ่มด้วยการที่ผมเสนอรูปแบบการเก็บข้อมูล ให้เพื่อนๆลงความเห็น หลังจากนั้นก็จะมีเพื่อนคนอื่นๆ เสนอต่อ ทำให้การทำงานดำเนินขึ้น
- Related info/link/reference
      nothing