在数据库中定义外键还是在应用程序的代码部分中定义外键更好?
MySQLUnique Key
和Primary Key
MySQL之间的主要区别是什么?
我正在为 Invoice.In 做一个小应用程序,表格将是这样的
=== invoice ===
id (pk)
customer_id (fk)
invoice_title
invoice_issue_date
due_date
description
created_by
updated_by
created_at
updated_at
=== invoice_items ===
id (pk)
invoice_id (fk)
customer_id (fk)
product_name
unit_cost
quantity
apply_tax1
apply_tax2
discount
description
created_by
updated_by
created_at
updated_at
=== customers ===
id (pk)
business_email
business_name
customer_name
business_address
town/city
state/province
postalzip_code
country
phone
mob
fax
created_by
updated_by
created_at
updated_at
=== estimates ===
id (pk)
address
estimate_title
estimate_no
purchase_order_no
estimate_date
description
created_by
updated_by
created_at
updated_at
=== estimate_items ===
id (pk)
estimate_id (fk) …
Run Code Online (Sandbox Code Playgroud) 我有customers
. 该customers
表是这样的
+------------------+
| Customers |
+------------------+
| id (PK) |
| business_email |
| business_name |
| customer_name |
| payment_terms |
| currency |
| business_address |
| city |
| state |
| postal_code |
| country |
| phone |
| created_at |
| updated_at |
+------------------+
Run Code Online (Sandbox Code Playgroud)
现在,我希望把送货地址在我的应用程序,客户可以任意提他的航运address.SØ我做了一个额外的表shipping address
像这样
+------------------+
| Shipping Address |
+------------------+
| id (PK) |
| contact_name |
| contact_address |
| delivery_address |
| created_at …
Run Code Online (Sandbox Code Playgroud)