Re: OO vs. RDB challenge

From: Costin Cozianu (c_cozianu_at_hotmail.com)
Date: 03/11/05


Date: Fri, 11 Mar 2005 08:00:53 -0800

Dmitry A. Kazakov wrote:
> On Wed, 09 Mar 2005 13:06:10 -0800, Costin Cozianu wrote:
>
>
>>Allegations have veen made recently (Application vs. Business Logic
>>thread) that only if we had enough peristent RAM so that we can get rid
>>of Oracle and its ilk, milk and honey will flow all across the OO land
>>now freed from Object Relational (Psychological) Impedance Mismatch.
>>
>>Claims have been handwaved across this newsgroups that core
>>functionality implemented by DBMS engines was not needed because it
>>would be trivially covered by the brave OO coders writing their ADTs on
>>a case by case basis.
>>
>>Since this is old news, I thought I refer those brave OO coders to
>>something I created specifically for such occasions:
>>
>>http://c2.com/cgi/wiki?ManyToManyChallenge
>>
>>I'm waiting to see how OO weenies out there put their code where their
>>mouth is.
>>
>>In particular I would stress the requirement that whatever class or
>>object (for object based, Java Script kind of guys) you create to manage
>>the many to many relationship , it should be usable from the calling
>>context without any fear of deadlock or spurious results in a
>>multi-threaded environment. Again, persistence is not an issue -- data
>>need not be persisted (imagine you had your nvram or whatever).
>
>
> OK, but let's make the challenge little more realistic:
>
> 1. Each user encapsulates a task running in parallel to others.
>
> 2. The user task:
>
> sleeps an arbitrary period of time from 1..10ms.
> undertakes one of the following actions at random:
>
> 2.a. Read Usenet (and post reply)
> 2.b. Post Usenet (new message)
> 2.c. Join a group (randomly)
> 2.d. Leave a group (randomly)
> 2.e. Create a new group
> 2.f. Change the profile (randomly)
> 2.g. Create another user
>
> The user profile determines the distribution of the probabilities over
> 2.a..g. Let's have three profiles Hardcore_Fan, Waver, Troll.
>
> After 1000 cycles a user task ends and so the user reaches Nirvana.
>
> 3. The Usenet is a blackboard of messages. When a user reads it, he does
> only unread messages. If the message is from him he ignores it. If it is
> from another user he posts either "cool" or "rubbish" depending on if the
> poster was from any of his groups. When he is not a member of any group he
> ignores the message.
>
> 4. Groups without users cease to exist.
>
> Show me SQL code, then I will post mine.
>

Your challenge is irrelevant as is contains the arbitrary constraint
that it has to be solved in SQL only. Make it Java + SQL or something
equivalent and one can easily spawn processes for each user and perform
the above actions by trivial SQL statements.

1.a -- retrieving messages by a reader
      SELECT FROM messages WHERE group_id IN
        (SELECT group_id from r_groups_users where user_id= :user_id)
2.a INSERT R_messages_users(msg_id,:user_id) VALUES (:msg_id, :user_id)
2.b INSERT INTO messages VALUES (...)
2.c INSERT INTO R_groups_users VALUES(:group_id, user_id)
2.d DELETE FROM R_groups_users where group_id= :group_id AND user_id=
:user_id
2.e INSERT INTO groups values (...)
2.f UPDATE users SET ... -- whatever profile values
2.g INSERT INTO users VALUES (...)

-- deleting groups without users
3. Delete from groups g WHERE NOT EXISTS
    (select * from r_groups_users WHERE r.group_id= g.group_id)

Having said that, the challenge becomes rather boring and unchallenging
as there is no new insight to be gained from it. The host language will
provide the source of random data, spawn threads, etc. The SQL DBMS
will perform the above data manipulation operations ensuring safety and
consistency in the presence of concurrent access.

In the meantime I have yet to see some OO code that solves even my very
modest challenge.



Relevant Pages

  • Re: SQL Mail
    ... > I'm having the same problem with sending mails from SQL. ... I've also went to SQL mail and set up a mail profile. ... > used to start SQL Server. ... > be a domain account if you are using an Exchange server as ...
    (microsoft.public.sqlserver.server)
  • Re: SQL Mail
    ... I'm having the same problem with sending mails from SQL. ... I've installed Outlook 2003, I'm logged on as the user for which the mailbox ... I've also went to SQL mail and set up a mail profile. ... "Troubleshooting SQL Mail with Exchange Server" ...
    (microsoft.public.sqlserver.server)
  • Re: My own security subsystem
    ... record your own permissions system - is this what you mean? ... system tables and was concerned that they might vary between versions of SQL ... Users have a profile with their account. ... >>> A user has an ACTUAL SQL login, instead of the generic login looking ...
    (microsoft.public.sqlserver.security)
  • Re: SQL Mail doesnt work. Please HELP!
    ... You have to set the sql services to run under an account other then "system" ... One thing to note mapi does not work well on systems with more ... the profile seems to randomly have strange behavior. ...
    (microsoft.public.sqlserver.security)
  • Operator error error:22022
    ... >the mail profile for this account works. ... >I set up sql agent to run on this service, ... >I try to add the administrator account and it doesnt test ... >figure what the heck the prob is. ...
    (microsoft.public.sqlserver.server)