Which datatype should I use for this?

Results 1 to 2 of 2

Thread: Which datatype should I use for this?

  1. #1
    Join Date
    Dec 1969

    Default Which datatype should I use for this?

    Hello! Which datatype should I use when I want to use the query "IN" on a field containing commated numbers like "1,42,2"?<BR><BR>I use Access 2000 at the moment, but I dont want to use anyting that will not work if I decide to upgrade to MS SQL-server.<BR><BR>Please Help! Thanks!

  2. #2
    Join Date
    Dec 1969

    Default RE: Which datatype should I use for this?

    You can use text (without any problems when you upsize to SQL Server)<BR><BR>Although you might want to think about this method, proper db-design (in most cases) would be creating an table wich covers the many to many relationship. For example:<BR><BR>tblStudents<BR>-----------<BR>StudentID<BR>StudentName<BR>Courses<BR><BR>tbl Courses<BR>----------<BR>CourseID<BR>Description<BR><BR>I think your current design has &#039;1,2,5,8&#039; in the Courses-field in the Studentstable to indicate which courses that student follows. Better is it to create an extra Student-Courses table, like this:<BR><BR>tblStudentCourses<BR>-----------------<BR>StudentID<BR>CourseID<BR><BR>This table would look like something like this:<BR><BR>StudentID CourseID<BR>1 1<BR>1 2<BR>1 5<BR>1 8<BR>2 1<BR>2 7<BR>etc. etc.<BR><BR>You get the point I guess. This design is better, if you want to know exactly why see some papers about database-normalization (for example MSDN question Q100139)<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts