Monday, 20 October 2014

What's it like to attend a community event like SQL Relay for the first time?

Following the recent SQL Relay event in Bristol, I had the opportunity to talk to a first time attendee, Claire, who has recently found herself in charge of the SQL Servers in her workplace. I asked her if she would mind sharing her thoughts on the event, so that others can get an insight into what it's like to attend for the first time.

What in the day did you most enjoy, and why?
Quite glad I got to see Alex Whittles' session [Using PowerPivot and DAX to Predict and Win Fantasy F1] because it was interesting to see how the power of Excel can be used, and seeing it applied in the way he did made it easier to understand.

So the real world example helped?
Yes, and quite a fun example too, and I do think it's something we could use as well.

Anything that didn't work in the event?
I don't know if it's because I arrived late to the start of the session [Claire had been speaking to a sponsor at the time, and had run into the start of the following session], but I found the BIML session quite hard to understand, as I felt I'd missed the introduction and found it quite hard to follow where he was going, but I can see it would be useful if you're trying to create multiple packages and don't want to run through and do the same thing again.

Had you come across BIML before?
No, although I had found something similar before, so I could recognise the concept, and it was nice to see you can build things in that way rather than just amending them.

Did you realise that was an intermediate session?
No, no I hadn't picked that up! I felt it was good, but I did feel a little behind.

There's often one session like that - particularly if it's not something you can use at work, and get familiar with, but it's good to introduce yourself to new concepts.
The NoSQL Session, Richard Munn's session - I was a bit confused by it I suppose,  because everything we do is entrenched in SQL, seeing outside that was hard; and then seeing the three different pieces of software he was demonstrating, I was trying to see how that could be of relevance to what we do, and if it would be better, but I found I couldn't clearly see.

So it's something you need a longer session to appreciate?
Yes, I think so, but it's great to see how the concepts work, and  it's good to see what else is out there.

Yes, it's just a taster, isn't it..
Yes. And his presentation style was funny, which helped - he did make me laugh!
And the last session, the "fun" one [Dave Morrison's SQL Fun Time Hour], I wasn't really sure what to expect, because it didn't really describe what it was about before I went, but it was really interesting, really good, and I was hanging on his every word. There was so much in there that was really useful.

So that's the one you'd like to see more of?
Yes, it was all real life, little bits of every day stuff you do all day and don't necessarily appreciate what issues it throws up in the background. I did really appreciate that one.

So would you go to more community events in the future?
Yes, oh yes - well, if I'm allowed to!

Some of the events are at weekends, or evenings - would you make it in your own time?
That's a different type of "Allowed To"!

It sounds like a positive experience then?
Yeah, oh yeah, I'd definitely try to go again.
It was just like a series of lectures, wasn't it, you just choose what you think might be most applicable and choose, and I like that, and it was friendly as well! I had thought it might be a bit more unfriendly, but it was fine.

Did that worry you - that it might be aimed at people who had been doing the job longer?
Yes, I know that some of the people I spoke to, the moment they spoke back to me I could only really smile as I didn't understand what they were saying, but I did also have conversations with people who I felt were in a similar position to me, which is good to know! And I was already expecting there would be less females there, so that wasn't a surprise.
I don't know if I feel strongly about gender mix, but didn't wan't to feel people were talking over my head just because I was female.

Did you find that?
No, I didn't get that at all.

I'm glad to hear that.
Yes, a good day, but now I just feel I could sleep for a year - It's a lot to take in, and reflect upon. I just hope I've got enough notes to convince my employer to send me to another one!

Thanks for your time, Claire, and I hope to see you at future events.

Sunday, 8 June 2014

Check constraints not what you thought they were?

I was recently adding a check constraint to a table in SQL Server, and noted some behaviour which surprised me, so I thought I'd share it with you. I've tried this on SQL Server 2012 and 2008 R2.

I added two fields, which either both needed to be null or both filled in. (Now, it is possible this requirement points to a normalisation requirement - but that's not the point at hand). So the check constraint is simply to ensure that either:

  • Field A is null AND Field B is null
OR
  • Field A is not null AND Field B is not null 

So I used the following check constraint:


USE tempdb


CREATE TABLE AllOrNothing
    
(
      
id INT IDENTITY(1, 1) ,
      
FieldA VARCHAR(100) ,
      
FieldB VARCHAR(100)
    )


ALTER TABLE AllOrNothing ADD CONSTRAINT UK_AllOrNothing 
    CHECK (
             (FieldA IS NULL AND FieldB IS NULL) 
           OR 
             (FieldA IS NOT NULL AND FieldB IS NOT NULL)
           )


Now, what surprised me was when I queried sys.constraints on this:



and again if I modify the constraint in SQL Server Management Studio:



The brackets have gone! Now, this isn't going to affect the functionality due to the precedence order of the logical operators, but will still have a SQL Developer looking at it and wondering if the intended functionality is what's been put in place. (Of course, the best way to be sure is to unit test your code).

I thought I'd blog about this, as whilst it doesn't change the function of what's been coded, it does change the form of it, which is unusual and was to me unexpected.