数据库设计:在数据库中保留分隔字符串是否不好 [英] Database Design: Is it bad to keep delimited strings in a database

查看:54
本文介绍了数据库设计:在数据库中保留分隔字符串是否不好的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此之前,我曾从事过一些项目,工作是将字段以逗号分隔或管道分隔的字符串存储为字段,该字段可能表示选项或类似名称。我想知道这样做是否被认为是不好的数据库设计,应该始终使用关系表,或者有时以这种方式存储数据是否可以接受?

解决方案

通常,这是一个坏主意



但是,标准化和性能之间是一个平衡。 / p>

如果未解析列表并且仅按原样显示,则最好存储以逗号分隔的列表,但是如果列表是针对单个列表进行解析的元素,则应遵循规范化的数据库架构


I've worked on projects before that would store fields in a comma-delimited or pipe-delimited string as a field, which might represent options or something simliar. I was wondering if it was considered bad database design to do this, and relational tables should always be used, or sometimes is it acceptable to store data in this fashion?

解决方案

Usually, that's a bad idea.

However, there is a balance between normalization and performance.

If the list isn't parsed and is simply displayed as-is, then it would be preferable to store the comma-separated list, but if the list is parsed for individual elements, you should stick to a normalized database schema.

这篇关于数据库设计:在数据库中保留分隔字符串是否不好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆