Alcibiade said:
Hello, I have a general question about db, dataset and so on
Is it right to create a db without relations but creating these in the
dataset?
There isn't a simple answer to that question. Databases are often used by
many different kinds of applications, but those different applications may
have common data needs. You may need to create relationships in the
database itself to aid in the execution of stored procedures and to be able
to enforce referential activity (you wouldn't normally want someone to be
able to delete a customer if there are related unfufilled orders for that
customer). So, creating the relationships in the database is very often
needed.
Being able to create relationships "on the fly" for disconnected data that
you've downloaded into a DataSet is a very powerful thing to be able to do
and you'd generally do that when you have an application-specfic reason for
needing those relationships.
I don't think you should think of this as an "either or" question. It's
more like which one best fits, not only the needs of one particular
application, but will that same solution be needed for many applications.
When i create the application, visual studio load all data inside
datatables but people say it is wrong: you should load only data you need,
use them and then release the memory......
So,i f I have a list of users in a table, is it correct loading all in the
dataset only their data and when the user is selected, load all data about
the choosen item?
Again, there is no one answer here, it really depends on the data. It is
true that you probably don't need to download 50,000 records into your
disconnected DataSet, when you want to be able to have an application that
let's the end user browse records. Instead you'd design your intial query
to get a smaller, eaiser to manage amount and then when the user has
exhausted those, you can go back to the database and get another chunk.
If, on the other hand, there isn't much data to get in the first place, then
sure, go ahead and get it all to avoid having to make another trip to the
database.
In this case what the advantage about using ado.net with binding,
datatabel and so on instead to make querys on fly on db?
Well, that's a very broad question that doesn't really make much sense. ADO
..NET is simply the name for types in the .NET Framework that allow you to
work with data (both connected and disconnected). You can certainly make a
query and execute it "on the fly" with ADO .NET, by working with a
Connection, a Command, and a DataReader. But, you may want to store the
data you just got from your query so a DataTable or DataSet might be
helpful.
I think what you are missing is that ADO .NET has types for working with
your data store in a "connected" way and a "disconnected" way.
As for data-binding, that really isn't relevant to how you are going about
getting your hands on the data. It only has to do with what you want to do
with the data once you've gotten it.
I read : by ado.net u can load all data in memory so that you can limit db
accesses tahey are slow a lot and it allows to limit traffic of data on
the net....
Most of that statement is true. But to say that it is slow is not really
accurate, as a general statement. Again, it depends on what you are
attempting to get. If you go to the database once and get 100,000 records,
you will save many trips to the database, but you'll wait a while for all
the data to be returned to your application. If you go to the database 10
times and get 10,000 records each time, each call will be faster, but you'll
make more database calls. The trick is to find the right balance between
how much data your appliciation needs at one time and how many times you
need to access your database for that data.
-Scott