Comment On tblIsThere

"I've been maintaining a 'certain' application for several months now," Trent writes, "it exists in a wonderful state of being partially properly written code, but mostly legacy garbage. I've done my best to avoid anything in the database realm, but a change request forced me to journey down that dark path." [expand full text]
« PrevPage 1 | Page 2Next »

Re: tblIsThere

2012-06-05 09:33 • by toth
So basically, he uses a single-column table as (totally unnecessary) scratch space for this existence check, when he could have just as easily has run SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '?' [table_name]. Assuming he really needed to check if the table existed in the first place.

He'd better have a really good justification for this...

Re: tblIsThere

2012-06-05 09:44 • by TheSHEEEP (unregistered)
382579 in reply to 382578
toth:
So basically, he uses a single-column table as (totally unnecessary) scratch space for this existence check, when he could have just as easily has run SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '?' [table_name]. Assuming he really needed to check if the table existed in the first place.

He'd better have a really good justification for this...


Madness?

Re: tblIsThere

2012-06-05 10:09 • by Nagesh (unregistered)
382581 in reply to 382572
toshir0:
PedanticCurmudgeon:
Nagesh:
SilentRunner:
It's amazing what words some people will come up with when trying to communicate with educated people.

I am lern two in past weeks: "ain't" and "massage."
At that rate you should have a decent vocabulary in about 50 years.
Please... you're no new guy here, Pedobearmudgeon. That scarecrow is *not* worth a talk. He's not even a joke getting old, he deserves only one thing : to be shot with *the Ignore gun*.


Scarecrow? Ain't this new word? I am massaging my hands to gether to find what it menes.

Re: tblIsThere

2012-06-05 10:11 • by Rootbeer
382582 in reply to 382551
Jack:
Metadata should be stored in XML in case the database is down.


What if the disk where the XML file is stored is offline also.

All access to metadata shall be done through a MetadataManager class (subclassed from a DataManager and, ultimately, an AbstractManager class) which maintains a list of MetdataManagerDriver objects that represent different ways in which the metadata can be stored: MetadataManagerXMLDriver, MetadataManagerDBDriver, MetadataManagerCSVDriver, MetadataManagerExcelCompatibleCSVDriver, etc...

To prevent overloading any one storage medium, a different MetadataManagerDriver will be used for each method call to the MetadataManager. The algorithm for choosing which MetadataManagerDriverSelector to use per call (MetadataManagerDriverRandomSelector, MetadataManagerDriverRoundRobinSelector, etc.) shall be implemented in the MetadataManagerDriverSelectorMediator.

Just hardcode all the config values for the MetadataManager right in the constructor for now.

Re: tblIsThere

2012-06-05 10:41 • by Nagesh (unregistered)
382583 in reply to 382581
Nagesh:
toshir0:
PedanticCurmudgeon:
Nagesh:
SilentRunner:
It's amazing what words some people will come up with when trying to communicate with educated people.

I am lern two in past weeks: "ain't" and "massage."
At that rate you should have a decent vocabulary in about 50 years.
Please... you're no new guy here, Pedobearmudgeon. That scarecrow is *not* worth a talk. He's not even a joke getting old, he deserves only one thing : to be shot with *the Ignore gun*.


Scarecrow? Ain't this new word? I am massaging my hands to gether to find what it menes.


dictionary.com:
scarecrow
[skair-kroh]   Origin
scare·crow
   [skair-kroh] Show IPA
noun
1.
an object, usually a figure of a person in old clothes, set up to frighten crows or other birds away from crops.
2.
anything frightening but not really dangerous.
3.
a person in ragged clothes.
4.
an extremely thin person.


I ain't understanding this.

Re: tblIsThere

2012-06-05 11:08 • by PedanticCurmudgeon
382584 in reply to 382581
Nagesh:
toshir0:
Please... you're no new guy here, Pedobearmudgeon. That scarecrow is *not* worth a talk. He's not even a joke getting old, he deserves only one thing : to be shot with *the Ignore gun*.


Scarecrow? Ain't this new word? I am massaging my hands to gether to find what it menes.
Well, toshir0, I hope you're happy. Now he's "learned" a third word.

Re: tblIsThere

2012-06-05 11:45 • by Nagesh
382585 in reply to 382555
PedanticCurmudgeon:
Nagesh (fake):
SilentRunner:
It's amazing what words some people will come up with when trying to communicate with educated people.

I am lern two in past weeks: "ain't" and "massage."
At that rate you should have a decent vocabulary in about 50 years.


This madarchod is bad version of imitating me. Atleast I have spell-checking feature in my browser all enabled now.

Re: tblIsThere

2012-06-05 11:50 • by Nagesh
382586 in reply to 382557
Diego:
Production code shouldn't execute DDL statements

I couldn't agree more. Yet, I know of a certain individual who, when asked what would be the best way to implement a relationship such as "user->list of friends" (typical of a social network), recommended creating a separate table for each user. That means, each user would have his/her own list of friends in his/her own personal, private table created on the fly. It would be interesting to see if the DB behind Facebook contains indeed over 900 million tables...


I have seen code like this in real live production system. It is only for some special group of users, but each user having individual table that define rights and privileges.

We found out after some user changes his single-sign-on identity name. Then lose all rights. This table never maintained, except by severe sql scripts kept in a Unix folder with label of IMP-DO-NOT-MESS-WITH-THIS.

Then we discover reason for lost rights for that user. This is still the way the system is running. This is system in place for client in Canada. Not develop by Indian programmers, but now being maintain by us only

I could never make this story anonymous, so I not submit it to WTF

Re: tblIsThere

2012-06-05 12:37 • by Nagesh (unregistered)
382588 in reply to 382571
Gyxi:
If you've been paying attention to quantum theory you'd know that UniverseIsThere cannot be represented in a simple boolean.


How about a nullable boolean then?
enum UniverseIsThere (is, ain't, FileNotFound);

Kant compile. Must the ' marke be require for spell ain't?

Pls send me the corect codez.

Pls do not ignore becuse I know you are think "bad Nagesh I punnish him by ignore" but even so you are think about Nagesh so I win.

Re: tblIsThere

2012-06-05 13:11 • by Meep (unregistered)
382589 in reply to 382533
Tasty:
emurphy:
Part of the implied WTF (which some have missed, or perhaps pretended to miss for the lulz) is that this is the only function that does anything with this table. There are some things that it could make sense for a program to test (whether it can reach the database server at all, whether it can create/insert/update tables) but this function and table would still be a WTF regardless.


No, it never makes sense. Production code shouldn't execute DDL statements, with the rare exception of CREATE TEMP TABLE.

One can test a program's database access and DML statement permissions by following them with a terminal SELECT. I don't think most live applications should have DDL permissions.


You do realize that a DBMS will routinely create temporary tables to execute large SELECT queries, right? There is absolutely nothing wrong with generating temp tables to handle your work, especially if they're only visible to your transaction.

For handling really large modifications to a table, often the best way to do it is through a CREATE ... AS SELECT because the DBMS doesn't have to do any locking: no one else can possibly access that table because it hasn't been created yet.

Certain systems absolutely do, for legal reasons such as provenance and auditing, require a fixed schema.

Many don't. The only good reason not to do DDL in a system that doesn't have a legal restriction on the schema is your concurrency model.

Oracle, for instance, isolates DDL from transactions. That is, (BEGIN DML DDL DML COMMIT) is quietly changed to (BEGIN DML COMMIT) DDL (BEGIN DML COMMIT), since, being Oracle, it happens in the most unexpected way possible.

Others, like PostgreSQL, handle DDL within a transaction just fine.

As to whether you have a genuinely good reason that your fields aren't fixed, and whether these tables you're constructing have any actual meaning in the real world, that's a whole other debate...

Re: tblIsThere

2012-06-05 14:14 • by Diego (unregistered)
382590 in reply to 382558
Jim:
Diego:
Production code shouldn't execute DDL statements

I couldn't agree more. Yet, I know of a certain individual who, when asked what would be the best way to implement a relationship such as "user->list of friends" (typical of a social network), recommended creating a separate table for each user.
You laugh, but this really happened at my workplace recently.
[...]
I guess this is the expected level of brainpower for a former Director of Big Things (recently demoted).


Well, the person who gave me the example teaches in a US College, he's a Professor. Perhaps he was thinking in an abstract way, but the information is way too often absorbed as "dogmatic way of doing things". No wonder, then, that some graduates come out with some abominations.

Re: tblIsThere

2012-06-05 14:36 • by M (unregistered)
382591 in reply to 382590
Diego:
Jim:
Diego:
Production code shouldn't execute DDL statements

I couldn't agree more. Yet, I know of a certain individual who, when asked what would be the best way to implement a relationship such as "user->list of friends" (typical of a social network), recommended creating a separate table for each user.
You laugh, but this really happened at my workplace recently.
[...]
I guess this is the expected level of brainpower for a former Director of Big Things (recently demoted).


Well, the person who gave me the example teaches in a US College, he's a Professor. Perhaps he was thinking in an abstract way, but the information is way too often absorbed as "dogmatic way of doing things". No wonder, then, that some graduates come out with some abominations.


I'm not really a DB person as I find them incredibly boring, but wouldn't the obvious way to look at it be similar to a OO approach in programming? Tables take on the role of classes, and each row would be an instance of that class. If you think of it this way, then creating a table for each user would be analogous to creating a separate class for each user...i.e. batshit insane.

Re: tblIsThere

2012-06-05 14:52 • by Jeff (unregistered)
382592 in reply to 382591
M:
creating a table for each user would be analogous to creating a separate class for each user...i.e. batshit insane.
I am intrigued by your ideas. Hmmm... an opportunity to implement a UserClassFactory Class!

No, you're right. Not enterprisey. Need more layers of factories.

Re: tblIsThere

2012-06-05 15:21 • by emurphy
382593 in reply to 382533
Tasty:
emurphy:
Part of the implied WTF (which some have missed, or perhaps pretended to miss for the lulz) is that this is the only function that does anything with this table. There are some things that it could make sense for a program to test (whether it can reach the database server at all, whether it can create/insert/update tables) but this function and table would still be a WTF regardless.


No, it never makes sense. Production code shouldn't execute DDL statements, with the rare exception of CREATE TEMP TABLE.

One can test a program's database access and DML statement permissions by following them with a terminal SELECT. I don't think most live applications should have DDL permissions.


Most, yes. Another exception would be an installer that creates a database and initializes its tables and such.

Nagesh:
This madarchod is bad version of imitating me.


You wash your hands out with soap, young man!

Re: tblIsThere

2012-06-05 18:16 • by Dave (unregistered)
382596 in reply to 382563
Ruakh:

Oracle has a built-in system table named "dual" with exactly one row. (Unlike some DBMSes, Oracle emits a syntax error on any query or subquery that doesn't have a FROM clause, so a single-row table is useful for things like "SELECT current_date FROM dual" and "SELECT 1 FROM dual WHERE EXISTS (...)" and so on.) Anonymous' code would hide that table by creating a non-system table with that name . . . and it would put two records in that user table, thereby causing lots of queries to return the wrong number of rows.

So Oracle databases have a table called DUAL which has only ONE thing in it. But you can fix this by making a DUAL with 2 things in it. But that breaks normal code.

Yet DUAL isn't a reserved word, or otherwise restricted to its valid if ill-named purpose.

Conclusion: Oracle is the Real WTF.
AMIRITE?

Re: tblIsThere

2012-06-06 05:58 • by ur (unregistered)
382597 in reply to 382521
¯\(°_o)/¯ I DUNNO LOL:
So TRWTF is that this function doesn't return FILE_NOT_FOUND?

Close - we have here a pentabool, able to return TRUE, FALSE, NULL, RECORD_NOT_FOUND and TABLE_NOT FOUND.

Re: tblIsThere

2012-06-06 05:59 • by ur (unregistered)
382598 in reply to 382597
ur:
¯\(°_o)/¯ I DUNNO LOL:
So TRWTF is that this function doesn't return FILE_NOT_FOUND?

Close - we have here a pentabool, able to return TRUE, FALSE, NULL, RECORD_NOT_FOUND and TABLE_NOT FOUND.

D'oh - I misread the table definition, the field isn't nullable, so this is just a boring old quadbool.

Re: tblIsThere

2012-06-06 07:01 • by Mr Clever Ideas (unregistered)
382599 in reply to 382592
Jeff:
M:
creating a table for each user would be analogous to creating a separate class for each user...i.e. batshit insane.
I am intrigued by your ideas. Hmmm... an opportunity to implement a UserClassFactory Class!

No, you're right. Not enterprisey. Need more layers of factories.

DDL should also include syntax for anonymous inner tables.

Re: tblIsThere

2012-06-06 10:14 • by M (unregistered)
382614 in reply to 382599
Mr Clever Ideas:
Jeff:
M:
creating a table for each user would be analogous to creating a separate class for each user...i.e. batshit insane.
I am intrigued by your ideas. Hmmm... an opportunity to implement a UserClassFactory Class!

No, you're right. Not enterprisey. Need more layers of factories.

DDL should also include syntax for anonymous inner tables.


Fine, fine, but I think multiple inheritance of tables should be avoided. Instead we should have abstract and interface tables with no actual columns, just ideas.

captcha: letatio = lettuce head

Re: tblIsThere

2012-06-06 12:03 • by Melvis (unregistered)
You guys are all crazy. He's obviously using this code to see if the DATABASE is there. Jeez...

Re: tblIsThere

2012-06-10 08:33 • by C (unregistered)
382916 in reply to 382562
Agention:
Bill Clinton:
tblIsThere? That depends on what the definition of the word "Is" is.


The definition of "Is" is is is is is is.
Umm, could you please properly paranthesize that? My brain's Language Interpretation Module just overflowed on me... :">

Re: tblIsThere

2012-06-12 10:41 • by nmn (unregistered)
383051 in reply to 382551
Metadata should be stored in XML in case the database is down...

And if the database is down? Is the metadata useful in any way? I doubt.
« PrevPage 1 | Page 2Next »

Add Comment