Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 05:51 PM
Kevin Hunter
 
Posts: n/a
Default pointer to feature comparisons, please

Hello List,

Short version: I want pointers to feature comparisons of Postgres vs
Oracle. Can the list help?

Long version:

I'm working with a student on a project for school. I'm trying to
teach "right" methods of thinking and doing things, such as making
the database/data model the authoritative source rather than adding
code to the application layer.

I originally had him code his project for Postgres, but for reasons
beyond our control we've had to move to Oracle. In designing the
schema we have need of a constraint that checks values in other
tables. The way that I currently know how to do this in Postgres is
with PLpgSQL functions. Then I add something like

CONSTRAINT away_team_is_playing CHECK ( NOT teamIsPlaying
( awayteamid, timeid ) )

to the table schema. No big deal, except that it seems Oracle can't
use anything other than a simple column constraint. He can't use any
custom functions like he could in Postgres, and we've yet to find a
solution to do what he needs.

I didn't immediately find anything last night on the postgresql.org
website, or a wider Google search.

So, motivation aside, what I'm wanting is a couple of pointers to
feature comparisons of Postgres vs Oracle. What else is going to
bite him while he works on this project? Would be handy to have this
reference since neither of us are really DB wizards. (Besides!
Isn't it good to tout what Postgres does better than it's
competition? :-) )

Thanks,

Kevin

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 05:51 PM
=?iso-8859-1?q?Rodrigo_De_Le=F3n?=
 
Posts: n/a
Default Re: pointer to feature comparisons, please

On Jun 13, 8:57 am, hunt...@earlham.edu (Kevin Hunter) wrote:
> So, motivation aside, what I'm wanting is a couple of pointers to
> feature comparisons of Postgres vs Oracle. What else is going to
> bite him while he works on this project? Would be handy to have this
> reference since neither of us are really DB wizards. (Besides!
> Isn't it good to tout what Postgres does better than it's
> competition? :-) )


This might help a bit on the SQL side:

Comparison of different SQL implementations
http://troels.arvin.dk/db/rdbms/

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-09-2008, 05:51 PM
Greg Smith
 
Posts: n/a
Default Re: pointer to feature comparisons, please

http://troels.arvin.dk/db/rdbms/ is where I go when I have to figure out
how to cope with someone's MySQL mess [this week: it lets you put an
arbitrary integer into a boolean column? seriously?]; it's also handy for
comparing against Oracle.

There is a helpful table
http://www-css.fnal.gov/dsg/external...-vs-pgsql.html I refer
to sometimes. It's from March of 2005 so several pieces are out of date.

Kevin Kline's "SQL in a Nutshell" also has some helpful suggestions on
syntax differences between the major SQL dialects, but it's even older.

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org/

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-09-2008, 05:52 PM
Stefan Kaltenbrunner
 
Posts: n/a
Default Re: pointer to feature comparisons, please

Kevin Hunter wrote:

[...]
> I originally had him code his project for Postgres, but for reasons
> beyond our control we've had to move to Oracle. In designing the schema
> we have need of a constraint that checks values in other tables. The
> way that I currently know how to do this in Postgres is with PLpgSQL
> functions. Then I add something like
>
> CONSTRAINT away_team_is_playing CHECK ( NOT teamIsPlaying( awayteamid,
> timeid ) )
>
> to the table schema. No big deal, except that it seems Oracle can't use
> anything other than a simple column constraint. He can't use any custom
> functions like he could in Postgres, and we've yet to find a solution to
> do what he needs.


well doing it that way is usually not a good idea at all (you cannot
actually use arbitrary queries in a CHECK constraint in pg either -
using a function to hide that is cheating the database - oracle might
actually be more(!) clever here not less ...). this why you can get into
all kind of weird situations with losing the integrity of your data or
running into serious issues during dump/restore for example.

What you need to do here is to use a trigger.


Stefan

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-09-2008, 05:52 PM
Kevin Hunter
 
Posts: n/a
Default Re: pointer to feature comparisons, please

At 3:26p -0400 on 13 Jun 2007, Stefan Kaltenbrunner wrote:
>> The way that I currently know how to do this in Postgres is with
>> PLpgSQL functions. Then I add something like
>>
>> CONSTRAINT away_team_is_playing CHECK ( NOT teamIsPlaying
>> ( awayteamid, timeid ) )
>>
>> to the table schema.

>
> well doing it that way is usually not a good idea at all (you
> cannot actually use arbitrary queries in a CHECK constraint in pg
> either - using a function to hide that is cheating the database -
> oracle might actually be more(!) clever here not less ...). this
> why you can get into all kind of weird situations with losing the
> integrity of your data or running into serious issues during dump/
> restore for example.


I was /hoping/ for a response like this! Thanks! Okay. I'll bite.
Why can't they be used in general? Is it the same problem that the
trigger has (below)?

> What you need to do here is to use a trigger.


From online docs regarding Oracle, this is not 100% safe either:

(http://download-east.oracle.com/docs...ev.101/b10795/
adfns_co.htm)
'To enforce this rule without integrity constraints, you can use a
trigger to query the department table and test that each new
employee's department is valid. But this method is less reliable than
the integrity constraint. SELECT in Oracle Database uses "consistent
read", so the query might miss uncommitted changes from other
transactions.'

It seems to me that there are certain situations where, especially in
a highly normalized data model, that you'd /have/ to have multiple
checks of even other tables. What theory am I missing if this is not
the case?

(I'm curious as well for another project on which I'm working that
does use pg and currently uses a function in just this fashion.)

Thanks,

Kevin

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-09-2008, 05:52 PM
Ron Johnson
 
Posts: n/a
Default Re: pointer to feature comparisons, please

On 06/13/07 15:02, Kevin Hunter wrote:
[snip]
>
> 'To enforce this rule without integrity constraints, you can use a
> trigger to query the department table and test that each new employee's
> department is valid. But this method is less reliable than the integrity
> constraint. SELECT in Oracle Database uses "consistent read", so the
> query might miss uncommitted changes from other transactions.'


Isn't it *supposed* to mis UNcommitted changes from other transactions?

--
Ron Johnson, Jr.
Jefferson LA USA

Give a man a fish, and he eats for a day.
Hit him with a fish, and he goes away for good!


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-09-2008, 05:52 PM
Joris Dobbelsteen
 
Posts: n/a
Default Re: pointer to feature comparisons, please

>-----Original Message-----
>From: pgsql-general-owner@postgresql.org
>[mailtogsql-general-owner@postgresql.org] On Behalf Of Kevin Hunter
>Sent: woensdag 13 juni 2007 22:03
>To: Stefan Kaltenbrunner
>Cc: PostgreSQL General List
>Subject: Re: [GENERAL] pointer to feature comparisons, please
>
>At 3:26p -0400 on 13 Jun 2007, Stefan Kaltenbrunner wrote:
>>> The way that I currently know how to do this in Postgres is with
>>> PLpgSQL functions. Then I add something like
>>>
>>> CONSTRAINT away_team_is_playing CHECK ( NOT teamIsPlaying (
>>> awayteamid, timeid ) )
>>>
>>> to the table schema.

>>
>> well doing it that way is usually not a good idea at all (you cannot
>> actually use arbitrary queries in a CHECK constraint in pg either -
>> using a function to hide that is cheating the database -

>oracle might
>> actually be more(!) clever here not less ...). this why you can get
>> into all kind of weird situations with losing the integrity of your
>> data or running into serious issues during dump/ restore for example.

>
>I was /hoping/ for a response like this! Thanks! Okay. I'll bite.
>Why can't they be used in general? Is it the same problem
>that the trigger has (below)?
>
>> What you need to do here is to use a trigger.

>
> From online docs regarding Oracle, this is not 100% safe either:
>
>(http://download-east.oracle.com/docs...ev.101/b10795/
>adfns_co.htm)
>'To enforce this rule without integrity constraints, you can
>use a trigger to query the department table and test that each
>new employee's department is valid. But this method is less
>reliable than the integrity constraint. SELECT in Oracle
>Database uses "consistent read", so the query might miss
>uncommitted changes from other transactions.'


For constraints, you don't want that to happen obviously...
In fact, if you run serializable the problems are even bigger.

In Oracle you should use SELECT FOR UPDATE for such constraints. They do
interfere with concurrency a bit, but you can in fact guarentee you
constraints (to a certain better point). It does require a lot of
thought nevertheless and its troublesome to get right.

In PostGreSQL there are more limitations to guarenteeing such
constraint. You can go a long with with SELECT FOR SHARE, but you can
run into problems when using serializable isolation. It's a bit better
on concurrency (it seems), but cannot enforce the constraint up to the
level Oracle can.

It's a tricky subject, it requires a lot of work for a single
constraint. Also you must be very aware of the limitations of such
constructs, since many are impossible to guarentee at this point in
time. In general, the world is less concerned with it.

>It seems to me that there are certain situations where,
>especially in a highly normalized data model, that you'd
>/have/ to have multiple checks of even other tables. What
>theory am I missing if this is not the case?
>
>(I'm curious as well for another project on which I'm working
>that does use pg and currently uses a function in just this fashion.)


They should use triggers. Also sometimes it possible to transform the
database schema in a way that you can enforce the constraint with
build-in (foreign key) constraints.

The general problem with these type of constraints is that they are
assumed to be true at ALL times. However it is possible to violate the
constraint, contradicting the assumption we just made. For triggers
there do not exist such assumptions.
Unless the database is going to support constraints with subqueries
(which is very hard to achieve and quite involved), we cannot rely on
the assuption that constraints are always true. In addition, don't
expect this type of support anytime soon on any opensource/commercial
database.

- Joris


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-09-2008, 05:52 PM
PFC
 
Posts: n/a
Default Re: pointer to feature comparisons, please

> Isn't it *supposed* to mis UNcommitted changes from other transactions?

Well, if the "uncommited change" is a DELETE of the row that allowed the
constraint check to pass, then when this delete is commited, your data is
no longer consistent.

Consider this :

CREATE TABLE A( attributes INT[], CHECK( is_valid_attributes( attributes
)) )

CREATE TABLE valid_attributes ( attribute_id INTEGER )

You want to check that A.attributes is an array of values, the only
allowed values being stored in valid_attributes table. If you delete a row
in valid_attributes, many rows in A can become invalid unless you use some
form of trigger on valid_attributes which would start to look a lot like a
foreign key ON DELETE trigger. If you insert stuff in A while concurrently
deleting a row in valid_attributes, you have problems. This is why foreign
key checks take share locks on referenced tables...


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 04-09-2008, 05:52 PM
Ron Johnson
 
Posts: n/a
Default Re: pointer to feature comparisons, please

On 06/13/07 16:59, PFC wrote:
>> Isn't it *supposed* to mis UNcommitted changes from other transactions?

>
> Well, if the "uncommited change" is a DELETE of the row that allowed
> the constraint check to pass, then when this delete is commited, your
> data is no longer consistent.


The DELETE should block, no?

--
Ron Johnson, Jr.
Jefferson LA USA

Give a man a fish, and he eats for a day.
Hit him with a fish, and he goes away for good!


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org/

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 04-09-2008, 05:52 PM
PFC
 
Posts: n/a
Default Re: pointer to feature comparisons, please

On Thu, 14 Jun 2007 00:09:20 +0200, Ron Johnson <ron.l.johnson@cox.net>
wrote:

> On 06/13/07 16:59, PFC wrote:
>>> Isn't it *supposed* to mis UNcommitted changes from other transactions?

>> Well, if the "uncommited change" is a DELETE of the row that
>> allowed the constraint check to pass, then when this delete is
>> commited, your data is no longer consistent.

>
> The DELETE should block, no?


Why ?

Foreign keys put an ON DELETE trigger on the referenced table besides
checking the referencing column on insert/update... If you just implement
a constraint, you only get half the functionality.



---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:35 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568