Closed tamminh2003 closed 1 year ago
@kennguyen291
DISCUSSION: Cái specilize của thằng bác sĩ thú y (Vet) thì mình có thể tạo ra một cái bảng many-to-many được không? hay là hiện tại chỉ muốn giữ cho nó đơn giản là mình hard code specializes vào trong table (comma-separated).
Ví dụ: Comma-separated case
ID | Name | Specializes |
---|---|---|
1 | Khang Nguyen | surgery,dermatology |
Pros: Đơn giản, không phải tạo many to many tables, tốc độ query cao. Cons: Không thể biết được trong hệ thống có bao nhiêu specilizes (có thể làm được nhưng mà phải viết complex query)
Many-to-many case
ID | Name |
---|---|
1 | Khang Nguyen |
ID | Specializes |
---|---|
1 | surgery |
2 | dermatology |
ID | Vet_Id | Spec_Id |
---|---|---|
1 | 1 | 1 |
2 | 1 | 2 |
Pros: Như vầy thì mình có thể query ra được là trong hệ thống có bao nhiêu specializes, add nhiều specializes cho một bác sĩ dễ dàng. Cons: Complex Entity Relationship (many to many)
Quyết định chọn cách 2: Sử dụng many-to-many table.
Một số thay đổi cho Entity
We need some sample data for the project. Such as Vet data. Customer data can be generated from the front end.
We need a database definition script (DDL) to create the tables (Customer, Appointment and Vet) We can create a seeding script that can be re run if we ever need to refresh the database.