Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the purpose of Datasets?

I want to understand the purpose of datasets when we can directly communicate with the database using simple SQL statements. Also, which way is better? Updating the data in dataset and then transfering them to the database at once or updating the database directly?

like image 551
Lizzy Avatar asked Oct 01 '11 13:10

Lizzy


People also ask

Why is a good dataset important?

Finding a quality dataset is a fundamental requirement to build the foundation of any real-world AI application. However, the real-world datasets are complex, messier, and unstructured. The performance of any Machine Learning or Deep Learning model depends on the quantity, quality, and relevancy of the dataset.

What is the data set?

A data set is a collection of related, discrete items of related data that may be accessed individually or in combination or managed as a whole entity. A data set is organized into some type of data structure.

How does a dataset work?

In the Datasette, instead of writing two tones to tape to indicate bits, patterns of square waves are used, including a parity bit. Programs are written twice to tape for error correction; if an error is detected when reading the first recording, the computer corrects it with data from the second.

What is data set with example?

A data set is a collection of numbers or values that relate to a particular subject. For example, the test scores of each student in a particular class is a data set. The number of fish eaten by each dolphin at an aquarium is a data set.


2 Answers

I want to understand the purpose of datasets when we can directly communicate with the database using simple SQL statements.

Why do you have food in your fridge, when you can just go directly to the grocery store every time you want to eat something? Because going to the grocery store every time you want a snack is extremely inconvenient.

The purpose of DataSets is to avoid directly communicating with the database using simple SQL statements. The purpose of a DataSet is to act as a cheap local copy of the data you care about so that you do not have to keep on making expensive high-latency calls to the database. They let you drive to the data store once, pick up everything you're going to need for the next week, and stuff it in the fridge in the kitchen so that its there when you need it.

Also, which way is better? Updating the data in dataset and then transfering them to the database at once or updating the database directly?

You order a dozen different products from a web site. Which way is better: delivering the items one at a time as soon as they become available from their manufacturers, or waiting until they are all available and shipping them all at once? The first way, you get each item as soon as possible; the second way has lower delivery costs. Which way is better? How the heck should we know? That's up to you to decide!

The data update strategy that is better is the one that does the thing in a way that better meets your customer's wants and needs. You haven't told us what your customer's metric for "better" is, so the question cannot be answered. What does your customer want -- the latest stuff as soon as it is available, or a low delivery fee?

like image 156
Eric Lippert Avatar answered Sep 20 '22 14:09

Eric Lippert


Datasets support disconnected architecture. You can add local data, delete from it and then using SqlAdapter you can commit everything to the database. You can even load xml file directly into dataset. It really depends upon what your requirements are. You can even set in memory relations between tables in DataSet.

And btw, using direct sql queries embedded in your application is a really really bad and poor way of designing application. Your application will be prone to "Sql Injection". Secondly if you write queries like that embedded in application, Sql Server has to do it's execution plan everytime whereas Stored Procedures are compiled and it's execution is already decided when it is compiled. Also Sql server can change it's plan as the data gets large. You will get performance improvement by this. Atleast use stored procedures and validate junk input in that. They are inherently resistant to Sql Injection.

Stored Procedures and Dataset are the way to go.

See this diagram:

enter image description here

Edit: If you are into .Net framework 3.5, 4.0 you can use number of ORMs like Entity Framework, NHibernate, Subsonic. ORMs represent your business model more realistically. You can always use stored procedures with ORMs if some of the features are not supported into ORMs.

For Eg: If you are writing a recursive CTE (Common Table Expression) Stored procedures are very helpful. You will run into too much problems if you use Entity Framework for that.

like image 44
TCM Avatar answered Sep 23 '22 14:09

TCM