Dev Shed Lounge
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherDev Shed Lounge

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 17th, 2003, 12:00 PM
Ctb's Avatar
Ctb Ctb is offline
An Ominous Coward
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jan 2002
Posts: 4,425 Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Weeks 10 h
Reputation Power: 0
Cool UnHoly Compound SELECT from Hell

Those of you who have faced similar problems with MySQL might find this amusing.

Code:
SELECT TOP 100 url, title, section FROM mIndex m LEFT JOIN pageInfo p ON p.uid = m.uid WHERE m.tid =
      (SELECT tid FROM termInfo WHERE termName = 'something') AND p.uid NOT IN
             (SELECT uid FROM mIndex WHERE tid IN (SELECT tid FROM termInfo WHERE termName IN('list', 'of', 'stuff')))

This was ultimately the only thing that Access would accept in order to do the kind of query I wanted.. and that's after I lowered my standards. It could've been much, much worse..

God what I wouldn't give for views....

Reply With Quote
  #2  
Old September 17th, 2003, 03:47 PM
kfickert's Avatar
kfickert kfickert is offline
Capt'n
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2001
Posts: 559 kfickert User rank is Corporal (100 - 500 Reputation Level)kfickert User rank is Corporal (100 - 500 Reputation Level)kfickert User rank is Corporal (100 - 500 Reputation Level)kfickert User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 8 h 20 m 17 sec
Reputation Power: 9
**Shudders** Access **Shudders**

I had to take a business class once that the professor wanted team to build a database for an example business to handle inventory tracking and everyone used Access since that is what they learned in their "Computers for Business" class. I, having skipped the class since I was a BETA tester for MS office, installed a copy of OSCommerce Suite on my webserver and turned in a one page word document to a link and username/password. Made a C+ on the project for being a smart *** about it. Story of my at college. Always did things my own way because it was better.

However at the dnd of the day: does it work?

Sometimes its not if its "how it should" be coded as much as so long as it works. After all, that is what the end user wants. They don't give a flying leap about whether the statements conform to ANSI '92 SQL syntax.

How "well" it is coded really is nothing more than honour amoung geeks.

Reply With Quote
  #3  
Old September 19th, 2003, 02:50 PM
dog135's Avatar
dog135 dog135 is offline
Doggie
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2003
Location: Seattle, WA
Posts: 751 dog135 User rank is Corporal (100 - 500 Reputation Level)dog135 User rank is Corporal (100 - 500 Reputation Level)dog135 User rank is Corporal (100 - 500 Reputation Level)dog135 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 10 h 38 m 25 sec
Reputation Power: 7
Oh quit your wining!

I work for the state and am currently working with the state DOP (Department of Personel) to pull information about employees for reports. Their database is not only NOT normalized, but they mix information about different departments into the same tables using overlapping codes with different meanings.

Doing a word count (in MS word) on one SQL quiry I'm currently using, it's over 1,400 characters w/o spaces. This quiry simply looks up general information on all employees at my work but pulls from 4 different tables, and has a 7 item WHERE clause on it. (All joined by "AND"s)

*WARNING, THOSE WEAK OF HEART SHOULDN'T READ THE FOLLOWING*

Washington State's DOP stores all their personel info in an Access database, available through an ODBC connection to any computer on their network. If I'm not carefull with my select statements, I'll accidently pull information about other departments.

But I'm not too worried about anyone getting my info since half the info they have in there is incorrect anyways. (or more) Plus trying to map the darn thing reminds me of where the term "spaghetti code" came from.
__________________
"Science is constructed of facts as a house is of stones. But a collection of facts is no more a science than a heap of stones is a house." - Henri Poincare

Reply With Quote
  #4  
Old September 19th, 2003, 02:57 PM
Ctb's Avatar
Ctb Ctb is offline
An Ominous Coward
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jan 2002
Posts: 4,425 Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Weeks 10 h
Reputation Power: 0
Quote:
All joined by "AND"s

You've never heard of IN() ?

Big SQL statements aren't uncommon, but compounding a bunch of SELECTs like that is just stupid. If I had VIEWs that would be no issue at all (are you listening MySQL... ARE YOU LISTENING???). And, I don't think you CAN normalize relations in an Access DB most of the time. I've tried with this one, and I just simply can't do it. There's very minimal data duplication (integer ids are assigned to text terms just to save disk space), but it's tough.

Hmmm... storing employee information in a spreadsheet organizer (Access) that's not transaction safe and can be accessed by pretty much anyone on the network.... that's smart.

Reply With Quote
  #5  
Old September 19th, 2003, 04:19 PM
drgroove's Avatar
drgroove drgroove is offline
pushing envelopes, not pencils
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Feb 2002
Posts: 6,225 drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Day 4 h 48 m 15 sec
Reputation Power: 174
Quote:
Originally posted by Ctb
are you listening MySQL... ARE YOU LISTENING???)


They're listening.

http://www.mysql.com/doc/en/ANSI_diff_Views.html

__________________
Give a person code, and they'll hack for a day; Teach them how to code, and they'll hack forever.
Analyze twice; hack once.
The world's first existential ITIL question: If a change is released into production without a ticket to track it,
was it actually released?


About DrGroove: ITIL-Certified IT Process Engineer - Enterprise Application Architect -
Freelance IT Journalist - Devshed Moderator - Funk Bassist Extraordinaire


Reply With Quote
  #6  
Old September 19th, 2003, 04:56 PM
Ctb's Avatar
Ctb Ctb is offline
An Ominous Coward
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jan 2002
Posts: 4,425 Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Weeks 10 h
Reputation Power: 0
Actually... that page was sort of my point.

Quote:
We plan to implement views in MySQL Server in version 5.1


I love their BS excuse for not having them too

Someday MySQL; someday you will be a real database server just like all the other little database servers.

Reply With Quote
  #7  
Old September 19th, 2003, 05:10 PM
drgroove's Avatar
drgroove drgroove is offline
pushing envelopes, not pencils
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Feb 2002
Posts: 6,225 drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Day 4 h 48 m 15 sec
Reputation Power: 174
Quote:
Originally posted by Ctb
Actually... that page was sort of my point.



I love their BS excuse for not having them too

Someday MySQL; someday you will be a real database server just like all the other little database servers.


LMAO... totally. I agree, but oh well... at least theres postgresql.

Reply With Quote
  #8  
Old September 22nd, 2003, 05:17 PM
dog135's Avatar
dog135 dog135 is offline
Doggie
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2003
Location: Seattle, WA
Posts: 751 dog135 User rank is Corporal (100 - 500 Reputation Level)dog135 User rank is Corporal (100 - 500 Reputation Level)dog135 User rank is Corporal (100 - 500 Reputation Level)dog135 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 10 h 38 m 25 sec
Reputation Power: 7
That's my one gripe with mySQL too.

As far as the DOP database being unnormal, they repeat the same information in several tables, (ie: Soc. Sec. Number, Name, etc.) they have FAR too many 1 to 1 relationships between tables, and don't have any unique fields.

The employee id is only unique per agency and sub-agency codes. So to get an employee name, I would have to use something like:

Select employeeName from <table name> where AgencyCode='300' and SubAgencyCode='C33' and personID=123456;


Reply With Quote
  #9  
Old September 22nd, 2003, 06:10 PM
Ctb's Avatar
Ctb Ctb is offline
An Ominous Coward
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jan 2002
Posts: 4,425 Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Weeks 10 h
Reputation Power: 0
LOL

Sounds like a typical Access spreadsheet to me.

Reply With Quote
  #10  
Old September 22nd, 2003, 08:34 PM
thedude thedude is offline
The Dude Abides
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2000
Location: grass valley,ca
Posts: 1,063 thedude User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 9 h 4 m 29 sec
Reputation Power: 10
You know, it's kind of funny to hear the complaints about mysql. Essentially it is a website database meant for basic/intermediate use. It didn't have support for transactions, etc.

Now, everyone wants this feature and that feature, pretty soon it's going to be like the upper end db's. And I'd bet the performance will suffer because of that. The quick, small footprint db will be replaced by the bigger, feature loaded, resource using, somewhat slower db.

I always worked under the assumption that if mysql didn't have all the features you needed you just used a different db.

Just a thought
__________________
The Dude
I'm the Dude. So that's what you call me.
That, or Duder, His Dudeness, Or El Duderino.
If, you know, you're not into the whole brevity thing

Reply With Quote
  #11  
Old September 23rd, 2003, 12:41 PM
dog135's Avatar
dog135 dog135 is offline
Doggie
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2003
Location: Seattle, WA
Posts: 751 dog135 User rank is Corporal (100 - 500 Reputation Level)dog135 User rank is Corporal (100 - 500 Reputation Level)dog135 User rank is Corporal (100 - 500 Reputation Level)dog135 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 10 h 38 m 25 sec
Reputation Power: 7
Hey, I'm not complaining too loudly. I love mySQL and I use it for my own web sites. There's only been a few times I've ran into problems with it, but they're pretty easy to work around.

I've even been trying to get my work to let me setup a linux box with mysql and perl on it. That'd be SO much better then what we have right now!

Reply With Quote
  #12  
Old September 23rd, 2003, 01:53 PM
Ctb's Avatar
Ctb Ctb is offline
An Ominous Coward
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jan 2002
Posts: 4,425 Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Weeks 10 h
Reputation Power: 0
The problem is that people try to pass it off as a RELATIONAL database management system. If it's good at what it does, that's fine, but if what it does doesn't involve being a RDBMS, don't try to pass it off as one. Same thing that irks me about Access. It makes a nice SQL-enabled (sort of) Spreadsheet tool. But, don't try to pass it off as a RDBMS or I WILL lay into you (not you in particular - whoever tries to pull that crap)... I'm not so passionate about cutting MySQL down to size, however... it's a lot closer to one than Access and it's still moving forward.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherDev Shed Lounge > UnHoly Compound SELECT from Hell


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump