简体   繁体   中英

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. 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)

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. If a user makes one selection, it's easy to see how the LineId will be inserted into 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? Thanks in advance for your help

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM