Unix Technical Forum

What is better to use?

This is a discussion on What is better to use? within the SQL Server forums, part of the Microsoft SQL Server category; --> I currently have two tables: 1: users id_user username 2: baned_users id_user i tought i could use something like ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2008, 02:52 PM
Igor
 
Posts: n/a
Default What is better to use?

I currently have two tables:
1: users
id_user
username

2: baned_users
id_user

i tought i could use something like this
1: users
id_user
username
is_baned

So would it be better to use two tables like in first example or one
table like in second example? Offcourse, not many users would be baned
(i hope). I currently have 59 joins with baned_users table in my
stored procedures, two of those are executed on every access to the
website (2xtop 20 users), what way should i use?

Sorry for my bad english.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2008, 02:53 PM
--CELKO--
 
Posts: n/a
Default Re: What is better to use?

Think in Sets! A table can be a set of entities and that table must
have *all* for the attributes of that entity. I think you need an
"access_status" attribute in the Users table or you need a
relationship table that puts a user_id and a resource_id paired.

>> Sorry for my bad English. <<


No problem. Please post DDL, so that people do not have to guess what
the keys, constraints, Declarative Referential Integrity, data types,
etc. in your schema are. Sample data is also a good idea, along with
clear specifications. It is very hard to debug code when you do not
let us see it.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-01-2008, 02:53 PM
Ed Murphy
 
Posts: n/a
Default Re: What is better to use?

Igor wrote:

> I currently have two tables:
> 1: users
> id_user
> username
>
> 2: baned_users
> id_user
>
> i tought i could use something like this
> 1: users
> id_user
> username
> is_baned
>
> So would it be better to use two tables like in first example or one
> table like in second example? Offcourse, not many users would be baned
> (i hope). I currently have 59 joins with baned_users table in my
> stored procedures, two of those are executed on every access to the
> website (2xtop 20 users), what way should i use?


I recommend the second method (one table). Using a separate table
should be reserved for situations where a subset of users have
significant amounts of extra data (e.g. blobs for the top 20 users).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-01-2008, 02:53 PM
Erland Sommarskog
 
Posts: n/a
Default Re: What is better to use?

Igor (jerosimic@gmail.com) writes:
> I currently have two tables:
> 1: users
> id_user
> username
>
> 2: baned_users
> id_user
>
> i tought i could use something like this
> 1: users
> id_user
> username
> is_baned
>
> So would it be better to use two tables like in first example or one
> table like in second example? Offcourse, not many users would be baned
> (i hope). I currently have 59 joins with baned_users table in my
> stored procedures, two of those are executed on every access to the
> website (2xtop 20 users), what way should i use?


The second design is the more natural design in my opinion. There could
be situations where the first design is better for performance, if you
often need to review the list of banned users, but that does not seem to
be a critical task in this case.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-01-2008, 02:53 PM
Igor
 
Posts: n/a
Default Re: What is better to use?

On Apr 17, 12:18 am, Erland Sommarskog <esq...@sommarskog.se> wrote:
> Igor (jerosi...@gmail.com) writes:
> > I currently have two tables:
> > 1: users
> > id_user
> > username

>
> > 2: baned_users
> > id_user

>
> > i tought i could use something like this
> > 1: users
> > id_user
> > username
> > is_baned

>
> > So would it be better to use two tables like in first example or one
> > table like in second example? Offcourse, not many users would be baned
> > (i hope). I currently have 59 joins with baned_users table in my
> > stored procedures, two of those are executed on every access to the
> > website (2xtop 20 users), what way should i use?

>
> The second design is the more natural design in my opinion. There could
> be situations where the first design is better for performance, if you
> often need to review the list of banned users, but that does not seem to
> be a critical task in this case.
>
> --
> Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se
>
> Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books...
> Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx


OK thank you all, i think i'll go with the one table then.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:33 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com