I'm pretty sure it actually exists haha
But in sql it is a field and inside it has data1,data2,data3 and so on. Like an array inside a field. Any idea?
There is no such data type.
You can put data like that in a regular varchar field, but then it will be complicated to use in any query, because there is no built in way to access comma separated items.
The usual way to handle data like that is to put it in another table.
As said befor. No such type.
And you should not keep comma separated values in a field. Instead create another table for the the id-value pairs.
Lets say you have a blog, where you use an Articles
table. Each article can have multiple Tags
. Instead of keeping all the tags for said article in single field as comma separated values, you should have table structure like this:
table: Articles table: Tags table: ArticleTags
---------------- -------------- -----------------
| article_id PK | | tag_id PK | | article_id FK |
| title | | name | | tag_id FK |
| content | | | | |
| | -------------- -----------------
----------------
In addition ArticleTags
table would have a composite primary key, made from both article and tag ids - PRIMARY KEY( article_id , tag_id )
.
精彩评论