更好地选择分层记录的数据库结构 [英] A better choice of database structure for hierarchical records

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

问题描述

在我的带有SQLite的Wpf VS应用程序中,我想使用我的旧数据表,

,其条目类似于下面的层次结构:



字段名称(F1 F2 F3 F4 F5 F6)

单元格内容(xyz * * *)约50,000行,字符串类型



字段F1,F2和F3的不同单元格内容的数量分别约为
10,15和20,在应用程序运行时动态添加或删除。



F2的内容取决于F1的内容。例如,

如果x =='fruits',那么y =='Apple'或'Mango''Banana'......

如果x =='动物',然后y =='猴子'或'大象'......



F3的内容同样仅取决于F2的内容。

因此,有序三元组(F1,F2,F3)的总数约为3000.



我对WPF,DataGrid,SQLite中的数据绑定知之甚少,但是没有进一步的

创建数据库的进展,我的意思是......什么是多个数据库,外键,数据库关系?

我想知道它是否可以正常使用1表创建由

创建表AAA(id int主键,F1 varchar(20),F2 varchar(20),F3 varchar(20),

F4 varchar( 512),F5 varchar(512),F6 varchar(512)),

这与电子表格的几乎相同。



非常感谢任何评论。

In my Wpf VS application with SQLite, I want to use my old data sheet,
whose entries are of something like an hierarchical structure below :

Field name (F1 F2 F3 F4 F5 F6)
Cell contents (x y z * * *) about 50,000 rows, string type

The number of different cell contents of the fields F1, F2 and F3 is about
10, 15 and 20 respectively, being added or removed dynamically when application runs.

And the contents of F2 depend on the the content of F1. For example,
if x == 'fruits', then y == 'Apple' or 'Mango' 'Banana' ...
if x == 'animals', then y == 'Monkey' or 'Elephant' ...

The contents of F3 depend only on the content of F2 similarly.
So total number of ordered triple (F1, F2, F3) is about 3000.

I managed to understand little about data binding in WPF, DataGrid, SQLite, but no further
progress in creating database, I mean... what is the multiple databases, foreign keys, database relations for?
I wonder if it's ok using just 1 table created by
create table AAA (id int primary key, F1 varchar(20), F2 varchar(20), F3 varchar(20),
F4 varchar(512), F5 varchar(512), F6 varchar(512)),
which is almost the same as spreadsheet's one.

Greatly appreciated if any comments.

推荐答案

我会的你知道你买了一本好的基础SQL书并经历过。它将帮助您获得大部分答案。不仅仅是针对这个问题,而是针对未来。



对数据模型化的理解总是有帮助的。



回到你的问题。这是一个小的6列表(数据表)。所以,实际上你可以继续使用它,如果你不想在将来扩展/扩展你的应用程序。



在一个非常规范化的数据库中,你将尝试删除存储在数据库中的任何重复数据。因此对于例如如果你看到Mango多次进入,你会创建一个名为Fruits的桌子并在这个桌子上添加水果。



当你想要为你的主要水果添加水果时表,您可以使用外键将它引用到Fruits表。因此,它将确保表的完整性。我的意思是,如果在一个国家你想要使用该应用程序,但他们称芒果为刚果。因此,不是重命名它的所有实例,您只需重命名一次,因为它只存在一次并使用标识符多次引用。
I would suggest that you buy a good basic SQL book and go through it. It will help you to get most of the answers. And not only for this question, but for the future.

Understanding of data modelization always helps.

Coming back to you question. It's a small 6 columns table (datasheet). So, practically speaking you can continue with it as is if you don't want to scale up/out you application in future.

In a very normalized database, you would try to remove any duplicate data being stored in the database. So for e.g. if you see Mango coming in multiple times, you would create a table called Fruits and add fruits to this table.

And when you want to add a fruit to your main table, you would reference it to Fruits table using foreign key. Thus, it will make sure the integrity of table. I mean what if in a country you want to use the application but they call mango a congo. So instead of renaming it's all instance you just have to rename it once because it exists only once and referenced multiple times using the identifier.


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

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