如何使用外键在表中接受零值 [英] how to zero value accepted in table using foreign key

查看:90
本文介绍了如何使用外键在表中接受零值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

select * form tbl_customer
column: id,name,price

select * from tbl_order

column:order_id,id,product_name





两个表关系外键..



但是tbl_order如何接受来自0的值tbl_customer



two table relationship foreign key..

but tbl_order how to accepted a 0 value from tbl_customer

推荐答案

您的数据库设计毫无意义。

1.为什么价格在tbl_customer表中?

2.为什么product_name在tbl_order表中?

重新查看数据库设计:

1. http://www.datanamic。 com / support / lt -dez005-introduction-db-modeling.html [ ^ ]

2. http://www.studytonight.com/dbms/database-normalization.php [ ^ ]

一些例子:

Your database design makes no sense.
1. Why is price in the tbl_customer table?
2. Why is product_name in the tbl_order table?
Re-look into the database design:
1. http://www.datanamic.com/support/lt-dez005-introduction-db-modeling.html[^]
2. http://www.studytonight.com/dbms/database-normalization.php[^]
Some example:
Table Name      Columns
tbl_customer    cust_id (primary key)
                cust_name 
tbl_product
                product_id (primary key)
                product_name
                price
tbl_order
                order_id (primary key)
                cust_id (foreign key to tbl_customer)
                product_id (foreign key to tbl_product)


这篇关于如何使用外键在表中接受零值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆