简体   繁体   English

使用相同的主键从另一个表的一列中插入多个可能的值

[英]Multiple possible values inserted into one column from another table while using the same primary Key

My title is probably not the best. 我的头衔可能不是最好的。 I simply cant articulate what I'm trying to do in the title. 我只是无法在标题中清楚说明我要做什么。 I have about 8 different tables for this project. 我为此项目准备了大约8张不同的表格。 Two specifically are giving me some issues. 具体来说有两个给我一些问题。 I've spent some time researching how to achieve third normal form, but I can't quite see how this may be possible with my current design. 我花了一些时间研究如何实现第三范式,但是我不太了解当前的设计是如何实现的。 I need some guidance to see how rows will be inserted while not increment a primary key per row. 我需要一些指导,以了解如何在不增加每行主键的情况下插入行。 I'll elaborate below. 我将在下面详细说明。

tblONe: (tblOneId, GUID, PolicyNum, LineNum) tblONe:(tblOneId,GUID,PolicyNum,LineNum)

LineNumTbl LineId, LineName LineNumTbl LineId,LineName

LineNumTbl
1 MCAL
2 MCNT
3 MCCG
4 MCGL
5 MCPD
6 MCTI
7 MCXC
8 MCXU

These will be selections made from a user then inserted into a DB. 这些是用户做出的选择,然后插入到数据库中。 A user may choose one of these or multiple. 用户可以选择其中之一或多个。

You can see my "tblONe" schema. 您可以看到我的“ tblONe”架构。 If a user makes one selection, it's easy to see how the LineId will be inserted into LineNum. 如果用户选择了一个选项,则很容易看到如何将LineId插入LineNum。 However, I'm running into an issue seeing how someone may choose multiple and keep the same primary key..( I auto increment based on row creation in other tables. ) 但是,我遇到了一个问题,看看有人如何选择多个并保持相同的主键。(我根据其他表中的行创建自动递增。)

My thought is it would look something like this. 我的想法是看起来像这样。

1001, (Random GUID), 1234ABC, 1
1001, (""), 1234ABC, 3
1001, (""), 1234ABC, 5
1001, (""), 1234ABC, 8

Is this possible to achieve? 这有可能实现吗? Or should I just create the table with 8 separate columns for these LineNums? 还是应该为这些LineNum创建带有8个单独列的表? Thanks in advance for your help 在此先感谢您的帮助

我建议您将tblOne的密钥tblOneId添加到LineNumTbl

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为同一主键合并一列中的值? - Combine values from one column for the same primary key? 将值从一个表插入到另一个具有不同主键的表中 - Insert values from one table to another having different primary key 从另一个表中为一个主键选择多行 - Selecting multiple rows from another table for one primary key 尝试从表的主键列中获取值并将其输入到另一个表的外键列中 - Trying to take the values from the primary key column of a table and enter it in the foreign key column of another table 从表中使用多个外键选择一个主键 - Select one Primary Key using multiple Foreign Keys from a table Postgres 从存在主键的同一表中的另一列插入表中的指定列 - Postgres insert into a specified column in the table from another column in the same table where a primary key exists 目标表具有主键时将数据从一个表插入到另一表 - Insert data from one table to another table while the target table has a primary key 如何用不是主键的另一个表的列来验证列的值 - how to validate values of a column with column of another table which is not a primary key 如何将一个表的主键值插入另一个表的外键列? - How do I insert primary key value from one table to foreign key column in another? Oracle:触发将值插入另一个表,并带有一个额外的自动递增主键列 - Oracle: Trigger to insert values into another Table with one additional auto increment primary key column
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM