Multiple relation in dataset.

  • Thread starter Thread starter zb
  • Start date Start date
Z

zb

Requirement:
Number of comma separated *files* (CSV) all related to each other have
to be read in such a way that they could easily be read to find
related data.

My idea:
Write a class with a method to add files which would be read split at
each new line and comma and then add to a seperate table in a dataset.
In essence, each datatable in the dataset will represent each file.
Can not use ODBC to read the files.

How to (Don't know or confused on how to do this in the best/easy
way) ....
-Add the relationship between files (the user could provide
this information)
-Get related information (basically, run a query)
-How to run this query? (dataview??)

Your Opinion:
Can you think of doing this in a better more efficient way?
What do you think of the concept that I am approaching?

Thank you for any help.
 
zb,

A dataset is a class that hold other classes by instance
DataTables and DataRelations.

A csv file is a bunch of records placed one after each other having not any
relation to each other.

That was what I was thinking after reading your message.

Cor
 
You can't run queries against a loaded dataset. What if you loaded the data
into a database and queried it?

You can try loading them into multiple tables in the same dataset, then set
up relations (check out the DataRelation class) to get like the children
that go with a specific parent, or something like that. That's about as
complicated as you can get.

Robin S.
 
Not true, the assembly I developed lets you run queries against a Dataset:
http:://www.queryadataset.com

zb,

Check www.codeproject.com for some code for reading CSV files into a
DataTable.

Regarding relationships: are the CSV files always the same set? If each
file always contains different data, then yes, the user must define the
relationship between the file contents.

To slice and dice the data as needed, queries are your best option.

Unless you are only going to look at the data in a CSV file once, the best
way to analyze data in CSV efficiently is always to convert it to another
format that supports indexing. A Dataset is fine, provided the number of
CSV files you plan to convert is less than 1000 and the number of rows in
each CSV file is less than 10000. If you expect your application to grow
beyond this, then go with a real database like SQL-Server Express.

Hope this helps
Ad.
 
Thank you all for your pronto response. I like Adrian's suggestion.

This is for a standalone application and data need not be retained and
is only used for processing info so the use of a database is not
required or rather I don't have the provision. :) Also, the CSV files
(upto 7 files) will be provided by the user at runtime.

Just like database, there will be "columns" in the CSV files that will
act as keys relating each of the files and the relationship between
files will be many-to-many kind.
From the discussion, how do I create relationships between the
different datatables that will be created and query them (something
like joins, I understand Joins are not available in DataSet). An
example will be greatly appreciated.

Thanks again.
 
zb,

You don't have to create relationships to join tables. The
www.queryadataset.com assembly I previously mentioned, includes complete
JOIN support for querying tables in a Dataset without creating
relationships. In fact, one of my customers is doing exactly what you are
attempting to do here (importing CSV files and querying across tables).

If you have more time on your hands than money, you may also find the
following article from Microsoft useful:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;325682

Hope this helps
Ad.
 
Back
Top