dbTalk Databases Forums  

Design question

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Design question in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Edward
 
Posts: n/a

Default Design question - 02-22-2010 , 09:28 AM






I've been tasked with designing an application to capture data about
sports clubs.

Let's say there are four different types of club - Soccer, Cricket,
Rugby and Tennis. For various reasons it is essential that data about
each of these will be stored in its own table.

I want to make use of the new datatype Geography to store the location
data. Unfortunately, LINQ to SQL doesn't yet support these. So my
thinking is to keep the location data in a separate table and
manipulate the data server-side to enable CRUD operations, but
ensuring that messages containing location information are in a form
that Visual Studio can deal with (by parsing in UDFs etc).

Here's the question. Would it be acceptable practice to have a
single, over-arching Location table which would store the location
data with a unique key consisting of the TYPE of the club PLUS the
UNIQUE ID of the club? Assuming a table of ClubType where Soccer =1,
Cricket = 2, Rugby = 3 etc. In the SoccerClub table let's say Hanley
Rovers has a UniqueID = 1. So, to get the location information;

SELECT LocationData from Location WHERE ClubType = 1 AND ClubID = 1

The alternative would be to have a Location table for each club type -
e.g. SoccerLocation, CricketLocation etc. with a 1:1 relation.

Thoughts? Apologies if I haven't expressed this very well.

Edward

Reply With Quote
  #2  
Old   
Nilone
 
Posts: n/a

Default Re: Design question - 02-22-2010 , 10:46 AM






On Feb 22, 5:28*pm, Edward <teddysn... (AT) hotmail (DOT) com> wrote:
Quote:
I've been tasked with designing an application to capture data about
sports clubs.

Let's say there are four different types of club - Soccer, Cricket,
Rugby and Tennis. *For various reasons it is essential that data about
each of these will be stored in its own table.

I want to make use of the new datatype Geography to store the location
data. *Unfortunately, LINQ to SQL doesn't yet support these. *So my
thinking is to keep the location data in a separate table and
manipulate the data server-side to enable CRUD operations, but
ensuring that messages containing location information are in a form
that Visual Studio can deal with (by parsing in UDFs etc).

Here's the question. *Would it be acceptable practice to have a
single, over-arching Location table which would store the location
data with a unique key consisting of the TYPE of the club PLUS the
UNIQUE ID of the club? *Assuming a table of ClubType where Soccer =1,
Cricket = 2, Rugby = 3 etc. *In the SoccerClub table let's say Hanley
Rovers has a UniqueID = 1. *So, to get the location information;

SELECT LocationData from Location WHERE ClubType = 1 AND ClubID = 1

The alternative would be to have a Location table for each club type -
e.g. SoccerLocation, CricketLocation etc. with a 1:1 relation.

Thoughts? *Apologies if I haven't expressed this very well.

Edward
I would prefer something like

Club (Id uniqueidentifier, ClubName nvarchar)
ClubLocation (Id uniqueidentifier references Club (Id), LocationData
geography)
SoccerClub (Id uniqueidentifier references Club (Id))
CricketClub (Id uniqueidentifier references Club (Id))
RugbyClub (Id uniqueidentifier references Club (Id))
TennisClub (Id uniqueidentifier references Club (Id))

Of course, there are caveats with such a design, as with any other.

Reply With Quote
  #3  
Old   
Sylvain Lafontaine
 
Posts: n/a

Default Re: Design question - 02-22-2010 , 11:34 AM



From the moment that he have chosen to separate the clubs into separate
tables, he is introducing caveat into his design but at least, this way,
relationships and the capability of the query engine to make the best usage
of indexes is preserved while still maintaining the number of tables at a
minimum.

Using a single field plus one type field is probably the worst solution in
term of performance because the same field can now contains multiple
foreign keys; thus removing the capabilities of seting up proper
relationships and greatly reducing the possibility of using indexes.

However, if this table is small and only has a few records and probably not
used very often; then making a full scan each time he need to join to it
won't be necessarily a big problem.

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Blog/web site: http://coding-paparazzi.sylvainlafontaine.com
Independent consultant and remote programming for Access and SQL-Server
(French)


"Nilone" <reaanb (AT) gmail (DOT) com> wrote

On Feb 22, 5:28 pm, Edward <teddysn... (AT) hotmail (DOT) com> wrote:
Quote:
I've been tasked with designing an application to capture data about
sports clubs.

Let's say there are four different types of club - Soccer, Cricket,
Rugby and Tennis. For various reasons it is essential that data about
each of these will be stored in its own table.

I want to make use of the new datatype Geography to store the location
data. Unfortunately, LINQ to SQL doesn't yet support these. So my
thinking is to keep the location data in a separate table and
manipulate the data server-side to enable CRUD operations, but
ensuring that messages containing location information are in a form
that Visual Studio can deal with (by parsing in UDFs etc).

Here's the question. Would it be acceptable practice to have a
single, over-arching Location table which would store the location
data with a unique key consisting of the TYPE of the club PLUS the
UNIQUE ID of the club? Assuming a table of ClubType where Soccer =1,
Cricket = 2, Rugby = 3 etc. In the SoccerClub table let's say Hanley
Rovers has a UniqueID = 1. So, to get the location information;

SELECT LocationData from Location WHERE ClubType = 1 AND ClubID = 1

The alternative would be to have a Location table for each club type -
e.g. SoccerLocation, CricketLocation etc. with a 1:1 relation.

Thoughts? Apologies if I haven't expressed this very well.

Edward
I would prefer something like

Club (Id uniqueidentifier, ClubName nvarchar)
ClubLocation (Id uniqueidentifier references Club (Id), LocationData
geography)
SoccerClub (Id uniqueidentifier references Club (Id))
CricketClub (Id uniqueidentifier references Club (Id))
RugbyClub (Id uniqueidentifier references Club (Id))
TennisClub (Id uniqueidentifier references Club (Id))

Of course, there are caveats with such a design, as with any other.

Reply With Quote
  #4  
Old   
Geoff Muldoon
 
Posts: n/a

Default Re: Design question - 02-22-2010 , 04:05 PM



Edward says...
Quote:
I've been tasked with designing an application to capture data about
sports clubs.

Let's say there are four different types of club - Soccer, Cricket,
Rugby and Tennis. For various reasons it is essential that data about
each of these will be stored in its own table.

I want to make use of the new datatype Geography to store the location
data. Unfortunately, LINQ to SQL doesn't yet support these. So my
thinking is to keep the location data in a separate table and
manipulate the data server-side to enable CRUD operations, but
ensuring that messages containing location information are in a form
that Visual Studio can deal with (by parsing in UDFs etc).
My view:

create table locations (location_id, location_information, ...)
create table club_types (club_type_id, club_type_desc)
create table clubs (club_id, club_name, club_type_id, ...)
create table location_suitability (location_id, club_type_id, ...)
create table club_locations(club_type, club_id, location_id, ...)

Why? Because there is the possibility (probability?) that clubs might
share a location (site suitable for both rugby and soccer for example).
And perhaps a club may have multiple locations.

Depending on scope, you might even have a location_activity_type (playing,
training, admin) table.

If your "various reasons" produce an overwhelming argument, then and only
then split the clubs into separate tables per type.

GM

Reply With Quote
  #5  
Old   
Geoff Muldoon
 
Posts: n/a

Default Re: Design question - 02-22-2010 , 05:04 PM



Edward says...
Quote:
I've been tasked with designing an application to capture data about
sports clubs.

Let's say there are four different types of club - Soccer, Cricket,
Rugby and Tennis. For various reasons it is essential that data about
each of these will be stored in its own table.

I want to make use of the new datatype Geography to store the location
data. Unfortunately, LINQ to SQL doesn't yet support these. So my
thinking is to keep the location data in a separate table and
manipulate the data server-side to enable CRUD operations, but
ensuring that messages containing location information are in a form
that Visual Studio can deal with (by parsing in UDFs etc).
My view:

create table locations (location_id, location_information, ...)
create table club_types (club_type_id, club_type_desc)
create table clubs (club_id, club_name, club_type_id, ...)
create table location_suitability (location_id, club_type_id, ...)
create table club_locations(club_type, club_id, location_id, ...)

Why? Because there is the possibility (probability?) that clubs might
share a location (site suitable for both rugby and soccer for example).
And perhaps a club may have multiple locations.

Depending on scope, you might even have a location_activity_type (playing,
training, admin) table.

If your "various reasons" produce an overwhelming argument, then and only
then split the clubs into separate tables per type.

GM

Reply With Quote
  #6  
Old   
Edward
 
Posts: n/a

Default Re: Design question - 02-23-2010 , 03:23 AM



On 22 Feb, 15:28, Edward <teddysn... (AT) hotmail (DOT) com> wrote:
Quote:
I've been tasked with designing an application to capture data about
sports clubs.

Let's say there are four different types of club - Soccer, Cricket,
Rugby and Tennis. *For various reasons it is essential that data about
each of these will be stored in its own table.

I want to make use of the new datatype Geography to store the location
data. *Unfortunately, LINQ to SQL doesn't yet support these. *So my
thinking is to keep the location data in a separate table and
manipulate the data server-side to enable CRUD operations, but
ensuring that messages containing location information are in a form
that Visual Studio can deal with (by parsing in UDFs etc).

Here's the question. *Would it be acceptable practice to have a
single, over-arching Location table which would store the location
data with a unique key consisting of the TYPE of the club PLUS the
UNIQUE ID of the club? *Assuming a table of ClubType where Soccer =1,
Cricket = 2, Rugby = 3 etc. *In the SoccerClub table let's say Hanley
Rovers has a UniqueID = 1. *So, to get the location information;

SELECT LocationData from Location WHERE ClubType = 1 AND ClubID = 1

The alternative would be to have a Location table for each club type -
e.g. SoccerLocation, CricketLocation etc. with a 1:1 relation.

Thoughts? *Apologies if I haven't expressed this very well.

Edward
Thank you one and all. Most instructive.

Edward

Reply With Quote
  #7  
Old   
TheSQLGuru
 
Posts: n/a

Default Re: Design question - 02-23-2010 , 08:33 AM



1) do NOT use GUIDs - astoundingly bad for performance
2) do not use LINQ to SQL, unless you are strictly doing stored procedure
access. And even then don't use it. :-)

--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net


"Edward" <teddysnips (AT) hotmail (DOT) com> wrote

Quote:
I've been tasked with designing an application to capture data about
sports clubs.

Let's say there are four different types of club - Soccer, Cricket,
Rugby and Tennis. For various reasons it is essential that data about
each of these will be stored in its own table.

I want to make use of the new datatype Geography to store the location
data. Unfortunately, LINQ to SQL doesn't yet support these. So my
thinking is to keep the location data in a separate table and
manipulate the data server-side to enable CRUD operations, but
ensuring that messages containing location information are in a form
that Visual Studio can deal with (by parsing in UDFs etc).

Here's the question. Would it be acceptable practice to have a
single, over-arching Location table which would store the location
data with a unique key consisting of the TYPE of the club PLUS the
UNIQUE ID of the club? Assuming a table of ClubType where Soccer =1,
Cricket = 2, Rugby = 3 etc. In the SoccerClub table let's say Hanley
Rovers has a UniqueID = 1. So, to get the location information;

SELECT LocationData from Location WHERE ClubType = 1 AND ClubID = 1

The alternative would be to have a Location table for each club type -
e.g. SoccerLocation, CricketLocation etc. with a 1:1 relation.

Thoughts? Apologies if I haven't expressed this very well.

Edward

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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.