17.06.2013 Views

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 8: Being Normal: Normalization and Other Basic Design Issues<br />

Let’s move on now to our second example — one where we create an associate table from scratch just so<br />

we can have a many-to-many relationship. We’ll take the example of a user and a group of rights that a<br />

user can have on the system.<br />

We might start with a Permissions table that looks something like this:<br />

PermissionID Description<br />

1 Read<br />

2 Insert<br />

3 Update<br />

4 Delete<br />

Then we add a Users table:<br />

UserID Full Name Password Active<br />

JohnD John Doe Jfz9..nm3 1<br />

SamS Sam Spade klk93)md 1<br />

Now comes the problem — how do we define what users have which permissions? Our first inclination<br />

might be to just add a column called Permissions to our Users table:<br />

UserID Full Name Password Permissions Active<br />

JohnD John Doe Jfz9..nm3 1 1<br />

SamS Sam Spade klk93)md 3 1<br />

This seems fine for only a split second, and then a question begs to be answered — what about when our<br />

users have permission to do more than one thing?<br />

In the older, flat file days, you might have just combined all the permissions into the one cell, like:<br />

UserID Full Name Password Permissions Active<br />

JohnD John Doe Jfz9..nm3 1,2,3 1<br />

SamS Sam Spade klk93)md 1,2,3,43 1<br />

233

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!