@Tuan_Nguyen
No problem I understand. I can see that you are doing your best on this.
I remember saving it many time during the day August 21st I was working upon it.
Answer for the questions:
- There were two different URLs, I distinctly remember both the diagrams to be open.
- No warnings were received when I hit the save.
There is certainly something unusual about this. I hope it was some action of mine, which I am unaware of right now, that lead to this. But the chances for this are very low. This does not seem to be an error which would be too costly to ignore!
Now on the same DBDiagram, there is a completely new DB design which I never did. Not sure what;s happening here.
Here is the schema:
//// -- LEVEL 1
//// -- Tables and References
// Creating tables
Table users as U {
id int [pk, increment] // auto-increment
full_name varchar
created_at timestamp
country_code int
}
Table countries {
code int [pk]
name varchar
continent_name varchar
}
// Creating references
// You can also define relaionship separately
// > many-to-one; < one-to-many; - one-to-one
Ref: U.country_code > countries.code
Ref: merchants.country_code > countries.code
//----------------------------------------------//
//// -- LEVEL 2
//// -- Adding column settings
Table order_items {
order_id int [ref: > orders.id] // inline relationship (many-to-one)
product_id int
quantity int [default: 1] // default value
}
Ref: order_items.product_id > products.id
Table orders {
id int [pk] // primary key
user_id int [not null, unique]
status varchar
created_at varchar [note: 'When order created'] // add column note
}
//----------------------------------------------//
//// -- Level 3
//// -- Enum, Indexes
// Enum for 'products' table below
Enum products_status {
out_of_stock
in_stock
running_low [note: 'less than 20'] // add column note
}
// Indexes: You can define a single or multi-column index
Table products {
id int [pk]
name varchar
merchant_id int [not null]
price int
status products_status
created_at datetime [default: `now()`]
Indexes {
(merchant_id, status) [name:'product_status']
id [unique]
}
}
Table merchants {
id int
country_code int
merchant_name varchar
"created at" varchar
admin_id int [ref: > U.id]
Indexes {
(id, country_code) [pk]
}
}
Table merchant_periods {
id int [pk]
merchant_id int
country_code int
start_date datetime
end_date datetime
}
Ref: products.merchant_id > merchants.id // many-to-one
//composite foreign key
Ref: merchant_periods.(merchant_id, country_code) > merchants.(id, country_code)
Also I just happened to click on the Version History I see that there are a lot of saves. Can those be used to retrieve the design?