I have been working with some basic sql databases and am designing an application and am wondering about having multiple values in 1 field. I am used to a relational DB model and am wondering if sql supports this. Here is an example delimited record:
PartID: part1
Description: Part Number One
Options: opt1|opt2|opt3
SubOptions: SA1~SA2~SA3|SA2|SA3~SA4
In U2, I would write a record just like this. In sql, you would have 3 tables witht he following value correct?
Part table:
PartID: part1
Description: Part Number One
Part Options table:
ID: 1
PartID: part1
Option: opt1
ID: 2
PartID: part1
Option: opt2
ID: 3
PartID: part1
Option: opt3
Part Options SubOption table:
ID: 1
PartID: part1
Option: opt1
SubOption: SA1
ID: 2
PartID: part1
Option: opt1
SubOption: SA2
ID: 1
PartID: part1
Option: opt1
SubOption: SA3
….and so on.
I have 2 questions. Can sql deal with multiple values in 1 field in a record? Basically saving an array in a record or a multi-dimensional array in a record. Iknow you can write and read on, but can you do selects on elements within the array?
Id what I descripted here the proper way to deal with the sample data structure that I have described?
Thanks in advance for any help. If there is a good document on this, please provide a link.
I’m afraid MySQL do not support multiple attributes in a single column. I suggest you to do that things using N:N relations. There are cases in which also a
VARCHAR/TEXTfield with multiple items separated with a string is ok ("one|two|three"), if you do not need to use these values to do joins…