Re: What does everyone else do for graphically displaying data?



Lew wrote:
mdR wrote:
anyway, one good example i've traced worked with only one table and
even that got kind of complicated managing one key id between db
objects and various gui objects. i guess there was ~a lot~ happening
behind the curtain that i've got to learn ;) iyo-does it ever get
easy?

Easier, yes, easy, no.

The matter of keys is complicated by a tendency for some to overuse integer surrogate keys, without identifying the so-called "natural" key that at least ideally identifies the row based on the attributes represented by the columns.

The "key id" I take you to mean is an integer SEQUENCE surrogate key maintained by the database to help determine row uniqueness, yes?

This surrogate key should be managed by the database - your object should use it, if at all, only as a very low-level handle for a database row, not for the object' own purposes. Sequenced surrogate keys exist only to make the database simpler, and are not (typically) part of the data model. (We'll ignore certain exceptions.) One should instead understand a row in the database to be determined by a "natural" column or set of columns, and usually there should be a UNIQUE constraint on that set of columns. [1]

Think of the object model - these attributes would be the ones that determine equals() in your object model.

The integer surrogate key should be determined, if you even need it at all, which you really don't, actually, except sometimes to underpin DAO layer machinery, by looking it up from the database, and in no wise should the middleware attempt to set or change it.

So you shouldn't any more have trouble "managing" (translation: "mucking with") the key ids.

[1]
"But so-called 'natural' keys can change in real life! People change SSNs all the time!" No, they don't do it all the time. They do it rarely. And when they do, it'll screw up your database schema. Then you'll fix it, manually. At which point their new SSN will uniquely identify them, so the key will still work as a key.

Don't get me started on data warehouse schemas. They're part of what make me so cynical about transaction db schemas.


I disagree with your view on natural keys versus what you call surrogate keys. The equals definition for a Point class would compare (x,y) tuples where a Polyline class could contain a Collection of Points and have an equals definition that compares the contained Points.
To represent a number of Polylines in a database you would have to give the Polyline some form of key, comparable with the objects identity it has in the Java program. Primary keys are more comparable with == than with equals.

Regards,

Silvio Bierman
.



Relevant Pages

  • Re: candidate keys in abstract parent relations
    ... relational model has no problem a priori with surrogate keys, ... A common rule within the database design community is to abjure ... constraint to enforce) at least one natural key for each table. ...
    (comp.databases.theory)
  • Re: candidate keys in abstract parent relations
    ... The use of a driver's license number to identify a person is actually the ... > I have never met a database designer yet, including myself, who doesn't ... information industry: content and conveyance. ... Surrogate keys are a hammer. ...
    (comp.databases.theory)
  • Re: Multi-Field Primary Key
    ... Surrogate numeric keys do solve a lot of technical ... problems for database and database application developers and many seasoned ... the judicious use of surrogate keys and often use them myself. ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Record number
    ... some individual field or some combination of fields taken ... Autonumbers are often used as "surrogate keys" for convenience in creating ... Some database designers _always_ use an autonumber surrogate ...
    (microsoft.public.access.modulesdaovba)
  • Re: File Auditing - Fast DB import and data manipulation
    ... the files into the database is not the best way forward. ... on either system (you'll need to download gunzip from gnuwin32 ... The databases I've dealt with (Oracle, SQL Server, Access, Postgres) ... So, I need some way to compare todays file, to yesterdays and see ...
    (comp.lang.ruby)