- Feature Articles
- CodeSOD
-
Error'd
- Most Recent Articles
- Stop Poking Me!
- Operation Erred Successfully
- A Dark Turn
- Nothing Doing
- Home By Another Way
- Coast Star
- Forsooth
- Epic
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
What about disabling constraints during database creation?
That doesn’t justify blind renaming, though. Java supports reflection so it may be very complicated to know if a method is safe to rename or not.
Admin
"repair the testing environment." - No version control!?
Admin
Where is this defined? I've never seen something like PEP for Java.
Admin
Uh, why not just do it the proper way and create the tables first in whatever order you want, and then create the constraints and relationships after all the tables are done?
Seems a much more sensible way to do it, creation order doesn't matter but process step order does.
Admin
Kinda seems to defeat the purpose of version control if you can't easily revert commits...
Admin
Here's a PDF of the Java Code Conventions (used at Sun back in the day).
Admin
Sure, conventions, not standards. Is just stupid.
Admin
Deleting the backup? Shouldn't that be a fireable offence?
Admin
I think he broke the database... No version control for those.
(Version control for databases... Sounds like something from the bad ideas thread)
Admin
The trwtf that this wasn't in version control
The various create table, create procedure scripts can be kept in version control.
Admin
Well yeah. I meant version control for the whole database.
Upon further review I'm not actually sure that happened. Unless the guy saw "Database error" and immediately thought "Oh, let's delete all the data, that'll fix it!"
Admin
We call these backups.
Admin
No, but you can keep the schema in the repository.
Admin
Not really a WTF in my opinion. The only wtf is a description, as Purist would care more about microarchitecture, pattern usage, code smell, that sort of thing. A code with underscored names, lowercase constants, capital case variables would hurt eyes for any competent Java developer.
If the code is not working anymore, the guy should see that in the your CI build status, no? or am I guessing it right and there there is none?...
Admin
OK, I know I go and do this kind of thing in my personal projects when I'm the only author, but on my company codebase? No way in hell.
Admin
TRWFT is "as per" when "per" is sufficient.
Admin
FTFY
Filed Under: SQL Purist
Admin
Deleted comments 1-3: Replaced with discussion about paulabean postings per TDWTF standards.
Deleted comments 8-22: Replaced with bitching about Discourse per TDWTF standards.
Admin
FTFY
Admin
OK, so not testing after each commit is a WTF....but..
Conclusion, the work illustrated had execution flaws, highlighted underlying problems.
Admin
Deleted comments 23-eleventy billion: because i could. replaced with output of markov chains.
Admin
I think I have worked with this guy. Not as much fun,though, as the one who decided, on a production code base, to refactor everything in accordance with the suggestions made by Netbeans, thus creating thousands of changes with no impact on performance, but a strong adverse impact on readability. Status? Junior programmer, new CS grad. Real world experience nil.
Admin
I don't see any WTF with the purist. An easy to read codebase does save time. And sometimes when dealing with code, things break. Business as usual. Also, if the "purist" wrote these comments it's an average coder, certainly not a purist.
Now, several people needing an entire weekend shift to repair a test environment because of a change to a database creation script, that's a proper WTF! Any halfway decent test environment is something that can be created with the click of a button. The test environment can and will be messed up, that's almost the purpose of it's existence. Rollback, click button, done.
Admin
Admin
Admin
Well, I don't think that is the proper way. I think ideally table creation, for each mainly self contained region of the schema, should start with all the tables that have no foreign keys and then work up, so that the database script can create constraints and relationships close to the affected tables. It is a bit like declaring variables and objects before you use them. Not everybody is visual and some people have difficulty with ERDs.For them it is clearer that you create customers and salespeople before you create sales orders, for instance. With a complex database (or a schema with several linked databases depending on your RDBMS) it is useful to be able to explore a restricted region of the schema without having to jump around a document that may be hundreds of kilobytes long. I've had to disentangle enough databases in my time for data mining that I've learned to appreciate when people take a little trouble over this (and also to be suitably annoyed with random scatter database scripts.)
Admin
Yeah, that could be difficult... [image]
I've seen database creation scripts well into the tens of megabytes
Admin
Well, thats exactly what I suggest doing in my comment - tables first, then everything else afterward.
Its how I write my SQL scripts - first the database, then the tables, then the constraints, then the relationships, then the seed data.
Not sure where you think your suggestion differs from mine...
Admin
He's creating constraints before he creates all of the tables.
Admin
the proper way to create and maintain those files is (AFAIAC)
>DB_CNAME.create.sql mysqldump --no-data --triggers --events DB_NAME
Admin
Ahh, in that case, his approach sucks :smile:
Admin
Admin
So, yours is bigger than mine. Was it intended in any way to be human readable? If you use (say) SQL Studio to design your database and use its tools to dump the database creator then any discussion of order is arbitrary, it isn't intended to be human readable. If your database creation script is of reasonable size and going to be reviewed by an anal retentive crusty DBA who is neurotic about security, table size and data size, being human readable is essential if you ever want it implemented. And they exist in surprising numbers, and your sales department will not love you if the DBA keeps delaying by demanding explanations.
Admin
I tried this on an SQL Server database and a DB2 database. Why doesn't it work? What am I doing wrong?
Admin
Translate as appropriate for different dbms.
Admin
You both suck. His has ordering problems and yours means I can't see the definition of a table in one place.
I HATE YOU ALL
Admin
I worked with a guy who couldn't stand C++ style "//" comments. He'd go through all the code manually converting them all to C-style. It was a C++ project.
// Hi Gary!
/*
Admin
The funny thing is that C has had "C++ style" comments for over 15 years, so now they are also "C style" comments.
Admin
This was almost 20 years ago, an old story... I think we could use // in C even then, maybe with a compiler flag.
Admin
Don't some databases have a way to disable constraints so you can do:
...what? Of course I'm not going to bother looking it up myself...
Admin
Yes, good point.
Admin
yes. because it can be a pain in the ass to define a circular FK relationship without that sort of thing.
if you can't temproarily remove constraints you have to issue an ALTER TABLE statement later.... and remember about it, to get the relationships right.
Admin
<No, I'm not summoning it; there's no need. Is there?
Admin
frack! not fast enough to catch proof of your hanzo edit!
Admin
I find it hard to conceive of that many relations being meaningful to anyone with a normal short-term memory. What are you doing with all that? Or were you mixing DML (which can easily get long-winded) with the DDL in order to populate some key tables?
Admin
Nobody posted go fmt without any context yet?
EDIT: @ben_lubar, am I Doing This Right™?
Admin
The schema is built incrementally over many releases, so you can't really keep it in the repository. You can keep the SQL that was used to build it at the time(s), but that's a different thing.
Our repository has views, packages, functions, etc. in it. Anything that is idempotent, which basically means anything that starts "CREATE OR REPLACE". Table creation or modification is not idempotent, so it only lives until the next release, when it is deleted.
Admin
Because you don't care about the quality of your company codebase?
Admin
Because the proper way is to create the tables and constraints together. The tables aren't done without the constraints, which is why they're included in the create table statement. You're trying to half-create the tables, then come back and fix them up with alter table statements. Why not do it right the first time?
Admin
This reminds me of someone who used to insist that stored procedure parameter names be
@camelCased
. Never mind that the default collation is case-insensitive, or that there were already 100+ procs using a different convention...