Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes ROWID next Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "ROWID next "big" thing." Watch "ROWID next "big" thing." New topic
Author

ROWID next "big" thing.

aadhi agathi
Ranch Hand

Joined: Apr 29, 2002
Posts: 263
Dear Java ranchers,
how about using the rowid as the record identifier.
rationale behind the scenes:-
=============================
1) record number is an unreliable means of identifying the
a given record. it is highly volatile.
2) Data class is higly reusbale and so making the file pointer
as the rowid won't hurt much. the changes required are not much.
3) solve the schema change problems. for instance what if the
flightid and day becomes a primary key some time in the future.
currently the find



say for example, the above code assumes that ONLY the first field
will be a primary key and it is not supporting the schema which will
be having more than one field as the primary key. just by adding
a hidden field called as the "rowid , equivalent to the file pointer
of the record " will solve all the worldly miseries.

4) the current delete which when applied to duplicate records
will delete the first find, not matter how dislikable it is.
help a fool to make a fool proof system.
regards,
Aadhi
[ January 26, 2003: Message edited by: aadhi agathi ]

Aadhi
aadhi agathi
Ranch Hand

Joined: Apr 29, 2002
Posts: 263
Peter,
please let me know your comments.
regards,
-Aadhi
[ January 27, 2003: Message edited by: aadhi agathi ]
Bernhard Woditschka
Ranch Hand

Joined: Sep 16, 2002
Posts: 89
Well, I'm not Peter,
but here come mt $0.02:
The data class relies on the first colum to be uniue i.e. this is the unique primary key.
That's a perfect qualification for identifying a record.
Bern
aadhi agathi
Ranch Hand

Joined: Apr 29, 2002
Posts: 263
Originally posted by Bernhard Woditschka:
The data class relies on the first colum to be uniue i.e. this is the unique primary key.
That's a perfect qualification for identifying a record.
Bern

ya, my concern will be about the reusability of the Data class. Consider when the flightId and Day becomes the primary key(a flight changing routes) or flightId and time (a flight changing origins) . for that matter any schema which is having a composite primary key won't be working with the given Data class. and so do delete.

i agree that Data class works fine if the primary key is atomic and there is no DML statements going on behind the back.

i feel that expecting a atomic primary key is too much of a luxury in a real application.
considering the benefits otherwise. anyway this is a normal way(rowid) of doing it in any RDBMS.
please let me know your thoughts
[ January 27, 2003: Message edited by: aadhi agathi ]
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by aadhi agathi:
i feel that expecting a atomic primary key is too much of a luxury in a real application.
I know plenty of people who frown upon composite primary keys, and insist on having a numeric primary key in every table (with the composite key demoted to an alternative primary key with a unique index slapped on).
anyway this is a normal way(rowid) of doing it in any RDBMS.
I am not sure what you mean here. You mention ROWID -- and indeed, the record number is perhaps most comparable to the ROWID which most/all RDBMSs support. Although ROWIDs are usually related to the physical position of the record in the table and not guaranteed to remain the same over time, they are stable within a session and in the RDBMSs I know there's nothing wrong with a read/modify/write cycle based on ROWID.
I don't really see a problem.
- Peter
aadhi agathi
Ranch Hand

Joined: Apr 29, 2002
Posts: 263
Originally posted by Peter den Haan:
I am not sure what you mean here. I know there's nothing wrong with a read/modify/write cycle based on ROWID.
I don't really see a problem.
- Peter

sorry for being vague. i too was saying that ROWID is the best way of doing it. but does the ROWID bases manipulation be a better option than record number based one considering that Data is reusable. .
aadhi agathi
Ranch Hand

Joined: Apr 29, 2002
Posts: 263
considering that recordnumber being the primary key, am i reasonable enough to say that
my model/facade should resemble.

1) is there any way of hardcoding the field[8], i mean, even if i check it is numberofseats column , it is a kind of hardcoding, which wont work if column name changes. i feel field[8] is OK as no RDBMS provide option to swap the column, say move from 8 to 5th position. But renaming of column it provides.

please let me know your thoughts.
[ January 27, 2003: Message edited by: aadhi agathi ]
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by aadhi agathi:
1) is there any way of hardcoding the field[8], i mean, even if i check it is numberofseats column , it is a kind of hardcoding
Correct. Many opt to hardcode the field names; I personally hardcoded the field positions because it was easier and I felt it was no worse than hardcoding the field names. Some might well disagree.
But.
First of all, there is just one Right Way[tm] to hardcode numbers -- public static final int NUMBER_OF_SEATS 8, et cetera. Second, hardcoding of this kind is IMHO only acceptable in the client (which is application-specific), not in the server (which is fully generic).
- Peter
aadhi agathi
Ranch Hand

Joined: Apr 29, 2002
Posts: 263
Originally posted by Peter den Haan:
But.
First of all, there is just one Right Way[tm] to hardcode numbers -- public static final int NUMBER_OF_SEATS 8, et cetera. Second, hardcoding of this kind is IMHO only acceptable in the client (which is application-specific), not in the server (which is fully generic).
- Peter

thanks Peter, for pointing this out.
[ January 28, 2003: Message edited by: aadhi agathi ]
 
GeeCON Prague 2014
 
subject: ROWID next "big" thing.