SQL数据库结构 [英] SQL Database Structure

查看:85
本文介绍了SQL数据库结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须为必须填写五种不同表格之一的客户创建一个数据库。每个表单有60到100个问题要回答,答案是布尔值,十进制或varchar(20)。



我需要了解什么是最佳实践要使用的数据库结构。



每个客户端应该有100列和一行,或者更好的做法是拥有100行,还是无所谓? br />


谢谢。

Hi, I have to create a database for clients who have to fill in one of five different forms. Each form has between 60 and 100 questions to answer and the answers are either boolean, decimal or varchar(20).

I need to understand what is the best-practice database structure to use.

Should I have 100 columns and one row for each client, or is it better practice to have 100 rows, or does it not matter?

Thank you.

推荐答案

我会使用三个表:一个用于客户,一个用于问题一个用于答案。
I would use three tables: one for the clients, one for the questions, one for the answers.


我建​​议你将答案保存在详细信息表中,例如:

I suggest you to save the answers in a detail table, something like:
SEQU_ID		INTEGER			// Sequence independed on anything other
CUSTOMER_ID	(Up to you what you have)
FORM_ID		(Up to you what you have) // Check whether this is
                                          // allready in QUEST_ID below
QUEST_ID	(Up to you what you have)
ANSWER_IS	INTEGER			// {BOOL, DEC, VARCHAR}
ANSWER_BOOL	BOOLEAN
ANSWER_DECIMAL	DECIMAL
ANSWER_CHAR	NVARCHAR(20)		// "NVARCHAR" is Unicode compatible 


这篇关于SQL数据库结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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