两个外键而不是主键 [英] Two foreign keys instead of primary

查看:140
本文介绍了两个外键而不是主键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,是否有可能创建一个没有主键的表,但是有两个外键,外键对总是不同的?
例如,具有 item_id 仓库 STOCK $ c>作为外键从 ITEMS WAREHOUSES 表。所以相同的项目可以在不同的仓库。表格视图:

I was wondering, is there any possibility to create a table without a primary key, but with two foreign keys, where the foreign keys pairs are always different? For example, a STOCK table with item_id and warehouse_id as foreign keys from ITEMS and WAREHOUSES tables. So same item can be in different warehouses. The view of the table:

item_id   warehouse_id   quantity
10        200            1000
10        201            3000
10        202            10000
11        200            7000
11        202            2000
12        203            5000


$ b b

还是我必须创建未使用的主键字段与自动增量或什么?
数据库是oracle。

Or do i have to create unused primary key field with auto increment or something? The database is oracle.

谢谢!

推荐答案

您需要复合主键

这篇关于两个外键而不是主键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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