Author |
Topic |
subbarao
Starting Member
4 Posts |
Posted - 2007-07-13 : 02:23:00
|
Hi,I want a column in a database table to store comma separated values.So can I store it as a string type(varchar,nchar) using commas?What are the other alternatives provided in Sql Server 2005--Subba Rao |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-07-13 : 02:30:38
|
This is not a good idea. You should normalize your database design instead. Please show us exactly what you are trying to do and why.Tara Kizerhttp://weblogs.sqlteam.com/tarad/ |
 |
|
subbarao
Starting Member
4 Posts |
Posted - 2007-07-13 : 02:45:30
|
quote: Originally posted by tkizer This is not a good idea. You should normalize your database design instead. Please show us exactly what you are trying to do and why.Tara Kizerhttp://weblogs.sqlteam.com/tarad/
Hi,My requirement:I have a table called geofence. It has a primary key geofence_id. Each geofence consists of a set of latitudes and latitudes. So I defined two columns latitudes and longitudes and their type is varcharSo in general how do people implement these types of requirements in relational databases?--Subba Rao |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-07-13 : 02:49:02
|
You haven't explained what part of your data is comma separated. What you have described so far is good.Tara Kizerhttp://weblogs.sqlteam.com/tarad/ |
 |
|
subbarao
Starting Member
4 Posts |
Posted - 2007-07-13 : 02:51:14
|
values in latitudes, longitudes columns--Subba Rao |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-07-13 : 03:08:31
|
What values though? We have geofences here too and we don't store comma separated values. We store the lat in one column, lon in one column (both as floats), then both lengths of the geofence in two different columns: eastwestlength and northsouthlength.Tara Kizerhttp://weblogs.sqlteam.com/tarad/ |
 |
|
subbarao
Starting Member
4 Posts |
Posted - 2007-07-13 : 03:57:42
|
Hi,Our requirement of geofence data contains not just one latitude value and one longitude value, but collection of them--Subba Rao |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-07-13 : 05:17:01
|
You can try to separate the values into two colums, Lat and Lon. Make a calculated column with the same name today so that you app still works. And then follow Tara's advice.Peter LarssonHelsingborg, Sweden |
 |
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-07-13 : 09:19:53
|
a bounding box is defined by two points on the globe, so you need 4 columns to store lat1, long1, lat2, long2.if you combine these to 2 columns you'll be sorry. or rather, you'll be back posting here in 6 weeks asking "how do I separate CSV stored in a single column?" elsasoft.org |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-07-15 : 18:52:46
|
Our geofences use one lat and one lon. The lat and lon are the center of the geofence. We then have a length for height and width. I believe our geofences are square, but the data shouldn't have to change for circles.Tara Kizerhttp://weblogs.sqlteam.com/tarad/ |
 |
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-07-15 : 21:40:23
|
makes sense, unless you need rectangles - which is generally what I need in apps  elsasoft.org |
 |
|
|