Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted
Updated 21-Apr-14 8:40am
v8
Comments
Sergey Alexandrovich Kryukov 21-Apr-14 14:46pm    
Just a note: database structure is not a "choice", this is a development step. :-)
—SA

1 solution

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.
 
Share this answer
 
Comments
Sor Emi 23-Apr-14 0:29am    
Thanks,
you pointed out exactly what I have to overcome with.
When i look around the records almost all the contents are same,
easy to bind in WPF but hard to handle with.
From your comments I got to realize more about the redundancy, management and integrity of DB records.
I have to use foreign key version rather than a flat one from the scratch.
Thanks in advance for any comments.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900