473,795 Members | 2,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datasets vs. OOP

I've seen an Introduction on ADO.NET with its Datasets on .NET TV and Iam
now wondering how it is realized/used in real world applications.

I don't believe that one would create a dataset and add relations to it and
so on for every table in the application, this would be a real mess and this
has nothing to do with OOP.

Normally, would would create a class Customer, a class Invoices, Positions,
Articles and so on.
But how can this be realized using Datasets? Datasets and encapsulating data
+ hiding implemention in classes seems to be a contradiction to me.

Sorry for me stupidness but I found no example explaining this.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
Jul 21 '05
45 2453
On Mon, 10 May 2004 02:05:31 -0700, "Frans Bouma [C# MVP]"
<pe************ ******@xs4all.n l> wrote:
bridge this gap, and if you look at ADO.NET 2.0 ,there's an object called an
ObjectSpace that addresses your concerns.
No, that's been removed from ADO.NET. It will be released separately.


Does anyone know why?

Because MS wants to make money with it or because it is too
controversial?
I'm with you here. DataSet objects are good at what they are for: being a
container for other containers in which data is stored which is related
(inside the table ! and between tables) based on information stored inside
the container at runtime.
DataSet objects are intended to map an SQL database.
Joins are very cheap btw, as they can be very well optimized. Subqueries on
the other hand ARE still very expensive.


Subqueries can be as well optimized as joins.
Regards
Alfredo
Jul 21 '05 #11
Cor Ligthert wrote:
When it is about dataset everybody seems to want to serialize to get an in
my idea older concept of dataprocessing.
Not necessarily. Serializing a dataset is performed for example when you
return it from a webservice (XmlSerializer) or when you return it from a
remoted method (Soap/Binary formatter or your own).
My idea about it is that people want to keep the three tier, while I do not
see much necessary anymore for it (or better to say, it conflicts for me in
some cases)


n-tier programming is about semantics. You can create a single assembly and
still have a 3-tier application, as long as you keep logical groups separated.

FB
--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP
Jul 21 '05 #12
Hi Frans,

I forgot to tell, serializing a dataset and deserialization is a piece of
cake when you use the stringreader and writer (which is not used in the
documentation as far as I know). This is all.

Serialize
\\\
Dim sw As New System.IO.Strin gWriter
ds.WriteXml(sw)
Dim mystring As String = sw.tostring
///
Deserialize
\\\
Dim sr As New System.IO.Strin gReader(mystrin g)
Dim ds2 As New DataSet
ds2.ReadXml(sr)
///

Cor
Jul 21 '05 #13
Alfredo wrote:
On Mon, 10 May 2004 02:05:31 -0700, "Frans Bouma [C# MVP]"
<pe************ ******@xs4all.n l> wrote:
bridge this gap, and if you look at ADO.NET 2.0 ,there's an object called an >> ObjectSpace that addresses your concerns.

No, that's been removed from ADO.NET. It will be released separately.


Does anyone know why?
Because MS wants to make money with it or because it is too
controversial?


It will be free, but I think they removed it for a couple of reasons:
1) integration of a sqlserver only tool inside the .NET framework is perhaps
not a wise thing to do, competition wise. (Oracle f.e. couldn't write its own
SQL engine / mapping engine for objectspaces)
2) it is used in Microsoft Business Framework (and longhorn's winfs), which
are both not part of the .net framework so by releasing it separately, you
can focus on aspects required for those two techniques and not necessarily
have to build in stuff you don't need.

Again, my own opinion, no-one knows for sure.
I'm with you here. DataSet objects are good at what they are for: being a
container for other containers in which data is stored which is related
(inside the table ! and between tables) based on information stored inside
the container at runtime.


DataSet objects are intended to map an SQL database.


Where did you get this information? Afaik, they are intented to store
resultsets.
Joins are very cheap btw, as they can be very well optimized. Subqueries
on the other hand ARE still very expensive.


Subqueries can be as well optimized as joins.


No, because you have to perform different data-algebra expressions with
subqueries than with joins. Check the execution plans on northwind for:

SELECT DISTINCT Customers.* FROM
Customers INNER JOIN Orders
ON Customers.Custo merID = Orders.Customer ID
INNER JOIN Employees
ON Orders.Employee ID = Employees.Emplo yeeID
Where Employees.Count ry = 'UK'

and:
SELECT *
FROM Customers
WHERE CustomerID IN
(
SELECT CustomerID
FROM Orders
WHERE EmployeeID IN
(
SELECT EmployeeID
FROM Employees
WHERE Country='UK'
)
)

Trace says: query 1 has a duration of 15 and 162 reads. QUery 2 has a
duration of 16 and 194 reads. It is hard to optimize outer query performance
based on a resultset from an inner query performance, because these
statistics are not known at compile time of the query (the join statistics
are, these are kept with the table, how many rows there are f.e.). So the
optimizer can easily optimize a join path by first trying to weed out as much
rows as possible by starting with the join with an operand the fewest rows. :)

FB

--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP
Jul 21 '05 #14

"Frans Bouma [C# MVP]" <pe************ ******@xs4all.n l> wrote in message
news:xn******** *******@msnews. microsoft.com.. .
I hate to spoil the party, Peter, but DataSets lack a lot in the OO area.

<snip>
You didn't "spoil the party".
I detected what I believed to be a question from someone who has some basic
misunderstandin gs about OO, and I was answering in that vein.
Jul 21 '05 #15
On Mon, 10 May 2004 04:40:02 -0700, "Frans Bouma [C# MVP]"
<pe************ ******@xs4all.n l> wrote:
Again, my own opinion, no-one knows for sure.
Very informative, thanks.
DataSet objects are intended to map an SQL database.


Where did you get this information? Afaik, they are intented to store
resultsets.


The resultsets returned from an SQL database, to manage them and to
submit the changes to the DBMS. The same as I said but with other
words.

I know they can be used with non SQL based data, but it is clear that
it is the main intention.
Subqueries can be as well optimized as joins.


No, because you have to perform different data-algebra expressions with
subqueries than with joins. Check the execution plans on northwind for:


I said that they can be as well optimized as joins, not that SQL
Server optimize them as well as joins ;-)
Trace says: query 1 has a duration of 15 and 162 reads. QUery 2 has a
duration of 16 and 194 reads.


Query 2 could be transformed in Query 1 by the optimizer.
Regards
Alfredo
Jul 21 '05 #16

"Frans Bouma [C# MVP]" <pe************ ******@xs4all.n l> wrote in message
news:xn******** *******@msnews. microsoft.com.. .
William Ryan eMVP wrote:
"cody" <pl************ *************@g mx.de> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. .
I've seen an Introduction on ADO.NET with its Datasets on .NET TV and Iam now wondering how it is realized/used in real world applications.

I don't believe that one would create a dataset and add relations to it
and
so on for every table in the application, this would be a real mess
and
this
has nothing to do with OOP. [...]
There's a philosophy known as OR/M (Object Relational Mapping) that
tends to bridge this gap, and if you look at ADO.NET 2.0 ,there's an object called an ObjectSpace that addresses your concerns.


No, that's been removed from ADO.NET. It will be released separately.

Nice to know, but I had quite a bit of info to the contrary, guess I need
to keep more up to date on it.
Normally, would would create a class Customer, a class
Invoices,Positi ons, Articles and so on. But how can this be realized using Datasets? The devil is really in the details and the problem here is that you may have many-to-many relationships which are a nightmare to handle with the current model. The short answer is create four tables, link them where you can.


m:n relations are definitions of a higher abstract form, like you find in
NIAM/ORM. In the relational model, they do not exist, in there you only

have FK constraints. You can semantically define relations between elements,
however you always require 1 or more elements:
1:1 relation can be: a PK - PK relation or a PK - FK(non PK)/UC relation
a m:n relation is always build with: a 1:n and a m:1 relation. Because you
can define an m:n relation and an 1:1 relation with different elements, you can also simply specify these elements and use them separately. For 1:1
relations this can be a real pain, and it's not hard to specify 1:1 relations with the same logic as 1:n relations are specified because they too are
defined between 2 elements (attribute sets, living in separate tables or in teh same table).

m:n relations are different because they require an intermediate element
where both ends of the m:n relation are related with. (order <- orderlines -> product) The problem begins when you want to save 2 elements which are
related via an m:n relation. What to do with the intermediate element? Create automatically or do you have to add this as well? I find it KEY that that
intermediate element is visible and has to be saved as well. Because if
that's the case, the whole relational model inside a dataset or object model is much simpler to understand and to work with and code stays consistent.
Datasets and encapsulating data
+ hiding implemention in classes seems to be a contradiction to me.
It can certainly be but not necessarily so. Like I mentioned in the
beginning, it's not a contradiction in that the object doesn't care where it's data comes from. A dataset whose structure can mimic the object
strucutre is a very natural fit. But I'm not going to pretend that there aren't a bunch of situations where the implementation is awkward.

Regrettably, OOP isn't a perfect model either and not everything can be
modeled by objects (why do I get the feeling I'm opening a can of worms with this last statement ;-) ). Rather, everything can probably be modelled, but not elegantly. Same with DataSet.


:D

I'm with you here. DataSet objects are good at what they are for: being a
container for other containers in which data is stored which is related
(inside the table ! and between tables) based on information stored inside
the container at runtime. This is very flexible, but doesn't work in OOP

very well, where you have fixed definitions and you extend these through
inheritance and polymorphism.
Sorry for me stupidness but I found no example explaining this.
I think that the result is that you need to consider the tools you have at your disposal. For years, Joins were really costly (and still are in many situations) in most RDMBS situations in many circumstances, but that has
nothing to do with Relational theory.


Joins are very cheap btw, as they can be very well optimized. Subqueries

on the other hand ARE still very expensive.
They can be cheap if done correctly, they can also be 'expensive' although
that's still a relative term. The point is that the implementation of a
model doesn't mean the model is weak. For years while i was too small to
read and before I was born, there was a fair amount of literature and
stereotypes that the relational model was mud just b/c the vendor
implementation didn't do X well for instance. Since I was sucking my thumb
at the time instead of using Oracle 1.0.1, I have to just look to what was
written and many themes and misconceptions seemed to be fairly commonplace.
But this didn't have anything to do with the model's failure and that was
ostensibly the analogy I was trying to make
FB

--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP

Jul 21 '05 #17
On Mon, 10 May 2004 04:25:25 -0700, "Frans Bouma [C# MVP]"
<pe************ ******@xs4all.n l> wrote:
n-tier programming is about semantics.


N-tier programming is about physical tiers. You still have a logical
client and a logical server.
Regards
Alfredo
Jul 21 '05 #18

"Alfredo" <al*****@nospam .es> wrote in message
news:40******** ******@msnews.m icrosoft.com...
On Sun, 9 May 2004 22:39:08 -0400, "William Ryan eMVP"
<do********@com cast.nospam.net > wrote:
Regrettably, OOP isn't a perfect model either and not everything can be
modeled by objects
OOP is not a data management model. The known data management models
are The Network Model (with its specialization: The Hierarchical
Model) and The Relational Model.

Ok, cool. I don't think I was making that point at all, so sorry if it
somehow sounded like I was.

Unfortunately many OO practicioners use the obsolete Network Model. There are a lot of toerh misaaplications of OOP that are far more complex
than just this issue.
On the contrary. However, the
pragmatic reality made the theoritical application a 'contradiction' ...
should I normalize to xNormal form or not? So many modelled tables to
performance issues over theoretical correctness even though the theory wastotally correct.
The dilemma is due to the lack of data independence of the current
DBMS products.

I'm not sure I understand what you mean here, but if your point is that
tightly coupling Data with the objects they represent is a problem, then yes
I agree.

Regards
Alfredo

Jul 21 '05 #19
Cor Ligthert wrote:
I forgot to tell, serializing a dataset and deserialization is a piece of
cake when you use the stringreader and writer (which is not used in the
documentation as far as I know). This is all.

Serialize
\\\
Dim sw As New System.IO.Strin gWriter
ds.WriteXml(sw)
Dim mystring As String = sw.tostring
///
Deserialize
\\\
Dim sr As New System.IO.Strin gReader(mystrin g)
Dim ds2 As New DataSet
ds2.ReadXml(sr)
///


I know, but when you subclass the DataTable class and add a property, it
will not be serialized into the data.

FB

--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP
Jul 21 '05 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2694
by: William Ryan | last post by:
At the risk of sounding like a Big 5 consultant, "It depends". 1) Strongly typed datasets rock, they are faster than untyped, use intellisense... but your reason for wanting to use them is important. I use them every day of my life, but I also don't use them every day of my life and there are reasons for both. 2) How much of your process is dependent on reads vs.
4
1738
by: Alpha | last post by:
I have a small Window application and through out the different forms I create a different dataset. At the begining I used the Tools to drag and drop the SqlDataAdapter, connection and dataset objects to the frist few forms but then later I removed those and created these objects in my code. I now see 3 datasets in the Solution Explorer panel part but not all the datasets that I have in my codes. Are these 3 datasets leftover from the...
9
2917
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got answered... There are articles on the new TableAdapters where it says that a key new advantage is that a single TableAdapter, which can have multiple queries, can be used on multiple forms. Now that was in an article on using TableAdapters with...
16
1938
by: Luqman | last post by:
Is it recommended to use datasets in ASP.Net 2.0 / VS.Net 2005 ? Best Regards, Luqman
4
9923
by: Ronald S. Cook | last post by:
I've always used untyped datasets. In a Microsoft course, it walks through creating typed datasets and harps on the benefits. It has you drag all these things around ..wizard, wizard, wizard... code gen, code gen, code gen. What's at the end looks slick, but then there's a ton of generated code that I'm going to have to maintain now. I.e. I like typing things myself (don't like wizards) so I can know exactly what I've done.
25
2780
by: Penelope Dramas | last post by:
Hello, I'm in a front of very serious .net redesign/rewrite of an old VB6 application. I had been asked to make it .NET 2.0 and would like to ask couple of questions regarding data access as this application is heavily data-centric around MSDE database. Would it be better to use custom business objects or extend
2
1370
by: S.Tedeschi | last post by:
Hi all gurus. I'm trying to switch to VS 2005, from VS 2003. I've an ASP.NET 1.1 app heavily relying on StronglyTyped DataSets, with lots of FindByKey..., dataSet.Tablename, and similar methods. Converting to ASP.NET 2.0 leaves dataSets' classes unconverted, as stated by M$; what's worse, I'm not able to use converted dataSets, nor new ones, but just non- typed dataSets declared directly in pages (or code-behind), and so I'm not allowed...
0
1222
by: S.Tedeschi | last post by:
Hi all; as posted some days ago, I'm converting an on-line app; I used to heavily rely on strongly-typed DataSets directly dropped onto pages, and so viewed by code(-behind) as well. In the next two weeks I discovered that such objects are no more directly usable in pages, namely in DataGrid which don't see them any more. Even if rebuilt in Component Designer, and so visible in code, DataSets are invisible in Page Designer, so now it's...
12
3605
by: BillE | last post by:
I'm trying to decide if it is better to use typed datasets or business objects, so I would appreciate any thoughts from someone with more experience. When I use a business object to populate a gridview, for example, I loop through a datareader, populating an array list with instances of a custom class in the middle tier, and then send the array list up to the presentation layer and bind the gridview to it. If I use a typed dataset, I...
9
1945
by: gardnern | last post by:
We have X number of data sets, of Y length each. For example... Small, Medium, Large and Red, Green, Blue, Yellow We need to generate a list of all possibilities Small Red
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10436
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9040
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.