将多个数据存储在一个 mysql 列中并单独检索数据 [英] storing multiple data in one mysql column and retrieval of data individually

查看:27
本文介绍了将多个数据存储在一个 mysql 列中并单独检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 mysql 表,用来给个别学生打分:

I have a mysql table used to score marks of an individual student:

studentID int(11)
studentname varchar(70)
maths_score int(11)
science_score int(11)
english_score int(11)

与维护数据库的原子性规则相比,此表效率低下.是否可以将数学-科学-英语的分数存储在一列中,并且可以单独检索?如果不可能,我该如何遵守原子性规则?

This table is in-efficient compared to the atomicity rule of maintaining databases. Is it possible to store marks of maths-science-english in one column, and can be retrieved individually? If its not possible, how do I conform to the atomicity rule?

推荐答案

是的,这是可能的.但是你的表格甚至不会是第一范式.

Yes, it's possible. But your table will not even be in First Normal Form.

为了符合这个cas中的原子性规则,你需要把你的表分成三个不同的表.一个用于存储学生数据,另一个用于存储课程(英语、科学),另一个用于存储每个学生/课程组合的考试成绩.

To conform to the atomicity rule in this cas, you need to separate your table in three different tables. One to store student data, another one to store courses (English, Science) and other to store test scores for each student/course combination.

这篇关于将多个数据存储在一个 mysql 列中并单独检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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