question

Matt Whitfield avatar image
Matt Whitfield asked

[Friday-quiz] What data type would you choose?

Ok, so it's Friday afternoon - and I don't know about your offices, but it's showing badly here. I thought I'd do a bit of database design investigation for my current client (even though I'm on a .NET contract). Anyway, some quiz questions: **You have to configure several hundred devices with a statically laid out configuration, which has defined elements. Do you:** * Create a schema which maps to the relationships within the static configuration and populate the devices from there? * Create an entity-property style table so that you can extend the configuration easily if you need to while retaining the ability to search relatively easily? * Stick it in a massive xml blob **Given that you've chosen to stick it in a massive xml blob do you:** * Put in an XML Namespace, qualifying the schema elements of the xml and then create an xml column that conforms to that namespace? * Put it in an untyped xml column and index it? * Use ntext **Given that you've chosen to use ntext, do you:** * Answer user queries using a view that you've created to pull out the common elements of the xml? * Answer user queries by searching the table for XML fragments using patterns or regular expressions? * Tell users that it's too hard to query the table, so it's not really possible to tell what is configured where? Head. Wall. Smash. Blood. Any of you had similar experiences?
xmlarchitecturedata-types
5 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Wimbush avatar image David Wimbush commented ·
Yep. This is often because the business has to have it ASAP but they just don't know what 'it' is. I sit with the development team and overhear stuff that makes my skin crawl. I'm not the most assertive guy in the world but I've had to learn to get straight into the discussion at that stage where change is still cheap.
2 Likes 2 ·
ThomasRushton avatar image ThomasRushton ♦♦ commented ·
Should this be a wiki?
0 Likes 0 ·
Matt Whitfield avatar image Matt Whitfield ♦♦ commented ·
I don't know - i've wikified it, but personally I don't really like the whole wiki thing, never really gelled with it.
0 Likes 0 ·
Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
Nah, this is educational.
0 Likes 0 ·
Matt Whitfield avatar image Matt Whitfield ♦♦ commented ·
Ok cancelled it again - unless i've got the wrong end of the stick?! It is Friday afternoon - oh so badly!
0 Likes 0 ·
Grant Fritchey avatar image
Grant Fritchey answered
BWA-HA-HA-HA It's not Friday afternoon here, yet, but you just put me in the mood. Yes, lots of similar experiences. My favoritee is the multi-statement table valued user defined functions system. The developers saw how UDFs worked, so they started putting them into the design. They had UDFs. Those UDFs called other UDFs and joined them together to create new structures. These were used with other UDFs combined with calls to sitll other UDFs that made structures that could be consumed by other UDFs. Basically, they built an object oriented data structure using UDFs. First time I saw it, I said, this won't work. I was dismissed out of hand because, it had been tested. A lot. In dev. With one row per table and one user. So, it was released to production, where there were tens of thousands of rows and hundreds of users. The rest, as they say, is history.
7 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

CirqueDeSQLeil avatar image CirqueDeSQLeil commented ·
+1 for grant as well. My question is, has anybody NOT experienced something like this?
3 Likes 3 ·
Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
@Fatherjack the first fix, I wasn't consulted on, resulted in an 86 table join (they just replaced the UDFs with views and went on their merry way). It took three tries and three different consultants (becuase they wouldn't let me do it, although the third consultant was EXTREMELY smart and I learned a lot from him).
2 Likes 2 ·
Matt Whitfield avatar image Matt Whitfield ♦♦ commented ·
Awesome - I'd love to have seen that one!
0 Likes 0 ·
Fatherjack avatar image Fatherjack ♦♦ commented ·
sounds awesome. How long did it take to fix, or did they just add hardware?
0 Likes 0 ·
Blackhawk-17 avatar image Blackhawk-17 commented ·
Did you save any of the execution plans?
0 Likes 0 ·
Show more comments
ThomasRushton avatar image
ThomasRushton answered
Depressingly familiar. I spent some time recently with a database that held call centre-type data (details of caller, type of query, etc) in an XML string. Stored in a SQL Server text field. Previous DBA said "No, we can't report on this". I took that as a challenge... Didn't take long to get a rudimentary report up & running. The real problem was that there were about 300 different "call types", each with their own little foibles once you got beyond the basic caller / handler information.
3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Matt Whitfield avatar image Matt Whitfield ♦♦ commented ·
You have to love stuff like this. I don't know how it's got to 2010 with this stuff still popping up. Is it that the percentage of people who really don't understand computing is the same - except that now there are more people - so the volume of poor code / architecture is actually going up?
2 Likes 2 ·
Matt Whitfield avatar image Matt Whitfield ♦♦ commented ·
+1, sorry for delay - just got some more votes. Hella-way lame.
1 Like 1 ·
ThomasRushton avatar image ThomasRushton ♦♦ commented ·
Just wondering if there's a way for users of more than a certain reputation to have more votes per day... Or if it's something that should be considered by the devs.
0 Likes 0 ·
Fatherjack avatar image
Fatherjack answered
--- Yes .
6 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Matt Whitfield avatar image Matt Whitfield ♦♦ commented ·
Me? Ask a question that was a bit frivolous?? What??? >:)
2 Likes 2 ·
Blackhawk-17 avatar image Blackhawk-17 commented ·
@Fatherjack - Bottom line... you answered the question as posed. +1
0 Likes 0 ·
Fatherjack avatar image Fatherjack ♦♦ commented ·
yeah, sometimes I am a little too literal for my own good. Was about to delete this as Grant has validated the question as "educational" when I was thinking it was a bit frivolous.
0 Likes 0 ·
CirqueDeSQLeil avatar image CirqueDeSQLeil commented ·
I have to agree, answered the question.
0 Likes 0 ·
Matt Whitfield avatar image Matt Whitfield ♦♦ commented ·
+1, sorry for delay - just got some more votes. Hella-way lame.
0 Likes 0 ·
Show more comments
Phil Factor avatar image
Phil Factor answered
I know the right answer to this. You write out the nText column as a series of files and query them via xPath with XMLStarlet using its 'sel' command
5 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Phil Factor avatar image Phil Factor commented ·
I've got this strange urge to actually try it out.
1 Like 1 ·
Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
Almost perfect. Are you sure you couldn't squeeze an Access database and a couple of spreadsheets in there somewhere though?
0 Likes 0 ·
Matt Whitfield avatar image Matt Whitfield ♦♦ commented ·
Yeah, I mean come on Phil - surely you can get a type-writer and punch-cards in there?!? :)
0 Likes 0 ·
David Wimbush avatar image David Wimbush commented ·
Don't forget to put the MDB file on a network share!
0 Likes 0 ·
Scot Hauder avatar image Scot Hauder commented ·
while you're at it, write the files to a source code repository then write a front end to extract the version the user wants before xQuerying
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.