Datasets vs. OOP

W

William Ryan eMVP

Alfredo said:
Something very frequent in the newsgroups.


This is unfortunately true.


Nobody said the contrary. It is clear that datasets are intended to
map SQL databases,
I respectfully disagree. If their intended purpose was to map back to SQL
databases, then what explains the tremendous support for XML and the fact
that you don't need to use a DB at all? It's a datasource that they are
meant to map back to, and that datasource can be a flat file, csv etc.

If they are clearly intended to map back to SQL Databases and aren't equally
intended to map to other data sources, then why can you use an Excel Sheet
or csv file, as flat and anti-sql as they get, Exactly like you would a SQL
DB, particularly in regard to the dataset. If anything you could make that
argument about a dataadapter, but again that's flawed because of the point I
just made.

If SQL Databases are the intended purpose, what explains the support for Web
Services, one of the highlights of ADO.NET that could write bits and pieces
of data to x number of hetergeneous data sources in part or in their
entirety? You could (and many do) write pieces of the Data retrieved form
th edataset ws for instance to an oracle/sql server/access db (which are all
obviously SQL) as well as HTML and XML Files which could be easily consumed
by say Infopath. I do it daily and it's in no way irregularl usage.

Moroever, you'll notice the word DataSource used extensively in the
documentation, not SQL Compliant Database. MS went through a good bit of
effort to draw this distinction precisely b/c it wanted to eliminate
confusion like this.

but you can do all you want with them.
Of course, but to use a network design in the 21 century does not make
a lot of sense.

I wasn't saying it did..hence the statement Network model etc. I coudl opt
totally out of all of these particular models and used a declarative model
coupled with a any concept I want, I'm free to invent it for that matter..
 
G

Guinness Mann

Jay said:
Martin's book discusses when you should consider one over the other, plus
various patterns to support an OO approach with either (DataSet or Domain
object) approach.
...
However if my "Domain Objects" had heavy logic to them, then I would use a
Domain Model and Data Mapper approach. See:
http://www.martinfowler.com/eaaCatalog/domainModel.html &
http://www.martinfowler.com/eaaCatalog/dataMapper.html patterns

Note: My Data Mappers would use a DataReader to read an row from the
database to create a new Domain object, passing the information for a row to
the constructor of the Domain object.

Hear, hear! All "business logic" is not necessarily what we
traditionally think of as "business" related. Even when it is, it often
isn't tabular. Think about a manufacturing application that has to
handle bills of assembly. The domain objects will almost assuredly
form some kind of tree structure while the native database
implementation will just as assuredly be tables.

In such a case the business objects will probably follow the composition
pattern using a data mapper to create each node.

The whole world isn't invoices and inventory.

-- Rick
 
A

Alfredo

I think that is a bit too much. Codd did most of the work

Of course. Codd had the genial idea of applying thousands of years of
advances in maths to the data management field and it has an inmense
merit.
, and before that,
there was mathematical theory, but not applyable to databases directly.
Agreed, most theoretical basis is founded way before Codd walked the earth,
but I find it a bit too much to give ancient mathematicans the credit for the
relational model ;)

Of course, I completely agree with you. But I was talking about the
origins of The Relational Model's strength.
( <- == is-a )

Person <- Employee <- Manager <- CEO
Person <- Employee <- Clerk
Person <- Employee <- Accountant

Now, if you set this up in NIAM or ORM (Halpin) you will use
supertypes/subtypes and which allow you to define relations directly to
'Manager' for example.

But NIAM and ORM are not relational. BTW I never have found them very
useful.

With The Relational Model you have to represent all these information
in several relations (tables). But it is not inheritance. It is an
application of Predicate Logic. Each relation (table) represents a
predicate and each tuple (row) a logical proposition.

Table inheritance does not make sense in The Relational Model. And it
is completely different to the OO class inheritance.
When you want to project this onto a relational model, you can't define is-a
relationships or supertype/subtypes.

Wen you project this onto a relational design the ORM types and
subtypes don't make sense anymore. You have to work in terms of
predicates and propositions.

You can define is-a relationships in many ways.

For instance:

create table IsA(name varchar(20), position varchar(20), primary
key(name, position));

insert into IsA values ('John', 'Manager');

This tuple means that John is a manager.

Relationships are relations and The Relational Model is all about
relations!

Another way:

create table Managers(name varchar(20) primary key);

insert into Managers values ('John');

This means: John is a manager.
You can 'try', but it is very hard.
Nijssen/Halpin mention 2 ways:
1) flatten the supertype/subtype hierarchy and store them all in 1 table,
with all attributes of all types in the hierarchy in that table, and
attributes which are defined with a lower type than the root supertype are
nullable. Furthermore, add a column which identifies the type of the entity
in a particular row.

Horrible practice that breaks The Relational Model. The result is not
a relational design.

BTW "flatten" does not make sense if you are talking about The
Relational Model. Predicates and propositions can't be flat.
2) define 1 table per subtype and add an FK constraint from the PK of the
subtype table to the PK of its supertype table (not THE supertype table!)

One table or more than one. But you can skip ORM and to do that
directly thinking in relational terms.
2) is close, however it doesn't symbolizes a hierarchy per se, because the FK
constraint just illustrates 'relationship between attributes' not an is-a
relationship.

The relation predicates might simbolize anything you want. The FK
constraint is just an integrity constraint. An is-a relationship is a
relation like any other. They are trivial to represent with The
Relational Model.

create table Employees(Id integer primary key, name varchar(20) , wage
numeric);

create table Managers(id integer primary key, department varchar(20),
foreign key (id) references Employees(id));

insert into Employees value(1, 'John', 50000);

This means: John is the employee with the Id 1 and earns 50.000. And
of course it stablishes that John is-an employee.

insert into EmpManagers values (1, 'Accounting');

This means: the employee with Id 1 is the manager of the accounting
department.

From these two propositions you can infere that John is-a manager. And
the DBMS too, if you declare the inference rules:

create view Managers as select * from Employees e, EmpManagers m where
e.Id = m.Id;

Select * from managers.

This should return:

Id Name Wage Department
-------------------------------------------
1 John 50000 Accounting

This means John is an employee, has the Id 1, earns 50.000 and he is
the manager of the accounting department.



Regards
Alfredo
 
A

Alfredo

however these 'clients' are servers for other clients. So strictly thinking
in 'client' and 'server' is not that great.

I agree it is not very good terminology.
Better is: 'consumer-role' and
'producer-role' in a given 'situation'.

I prefer applications-DBMS


Regards
Alfredo
 
A

Alfredo


I will look it.
O/R mappers are IMHO for solving overhead code: how to work with data with
OO constructs. You need overhead code to make that happen.

This is again the problem of the lack of precise terminology.

According to your definition ADO.NET could be considerd an O/R mapper.
And I don't see any problem in that.


Regards
Alfredo
 
G

Guest

Just a thought..

I did OOP represenation of a dataset before using DataViews.. Basically, my classes holds views of the data in a dataset using both DataView and DataRow..
There are problems with this though in the case of serializing because DataViews cannot be serialized..

Regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top