Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^7: (OT) Why SQL Sucks (with a little Perl to fix it)

by Theory (Beadle)
on Dec 12, 2005 at 17:44 UTC ( #516072=note: print w/replies, xml ) Need Help??

in reply to Re^6: (OT) Why SQL Sucks (with a little Perl to fix it)
in thread (OT) Why SQL Sucks (with a little Perl to fix it)

If the table is is 3NF, then that unique constraint across all keys holds.

I don't think that's quite true. Consider this simple example:

CREATE TABLE supplier (
  name TEXT

INSERT INTO supplier (name) VALUES ('Apple');     -- Computer
INSERT INTO supplier (name) VALUES ('Microsoft');
INSERT INTO supplier (name) VALUES ('Apple');     -- Records

SELECT * FROM supplier;
 id |   name    
  1 | Apple
  2 | Microsoft
  3 | Apple

This table is in the third normal form, in so far as I understand it, because "none of the non-primary key attributes is a fact about any other non-primary key attribute". However, you'll notice that there is a duplicate, in that "Apple" is listed twice. That's because there are two different companies named "Apple". So this table is technically in 3NF, but you cannot have a unique index across all of its columns.

That's not to say that this is a good example, or that you couldn't work around this issue in various ways, but it demonstrates, I hope, that 3NF does not mandate that all columns be unique.


  • Comment on Re^7: (OT) Why SQL Sucks (with a little Perl to fix it)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://516072]
[r@j]: I am new to perl script, seeking your advice for the following requirement in perl script - Need to retrieve the status of running process with the process name without using ps -ef command.
[marto]: As discussed yesterday SoPW
[Discipulus]: r@i see perlvar in the docs: $$ is the PID of the current running process. I suppose the name will be perl anyway

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2017-10-24 07:47 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (286 votes). Check out past polls.