Redian新闻
>
Database 中不能直接存Arrray吧?
avatar
Database 中不能直接存Arrray吧?# Database - 数据库
l*r
1
MySQL
For example, I want to create a table like:
FamilyID, Member_Names
10, [Tom, Bob, Kitty]
where Member_Names is of type Array (or list).
Instead, I have to do it like this:
FamilyID, Name
10, Tom
10, Bob
10, Kitty
And when query, aggregate the column Name to a array (list), like "select
Name from my_table where FamilyID = 10", then use the ResultSet to re-create
them into Array (I am using Java).
Am I right?
Thanks a lot.
avatar
I*e
2
Yes, that is the typical normalization work of the database.
avatar
a*s
3
select familyID, concat_ws(',', Member_Names) from my_table where FamilyID =
10 group by familyID;

【在 l********r 的大作中提到】
: MySQL
: For example, I want to create a table like:
: FamilyID, Member_Names
: 10, [Tom, Bob, Kitty]
: where Member_Names is of type Array (or list).
: Instead, I have to do it like this:
: FamilyID, Name
: 10, Tom
: 10, Bob
: 10, Kitty

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。