วันอังคารที่ 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