all groups > sql server programming > august 2004 >
You're in the

sql server programming

group:

multiple values


Re: multiple values Joe Celko
8/16/2004 2:22:29 PM
sql server programming:
[quoted text, click to view]
values for a field [sic]. <<

Let's get back to the basics of an RDBMS. Rows are not records; fields
are not columns; tables are not files; there is no sequential access or
ordering in an RDBMS, so "first", "next" and "last" are totally
meaningless. BY DEFINITION a column holds scalar values.

You have completely missed the most basic ideas of an RDBMS and are now
hunting for kludges.

[quoted text, click to view]
value will be an integer number, but how about when a field [sic] has
multiple choices? Should i
use a listbox with multiple select enabled for visual appearance. <<

Next mistake; you do not know about physical and logical levels in a
system. There is no such thing as a combobox in SQL; that is front end
stuff and has nothign to do with the database.

[quoted text, click to view]

I'll bet you have never read a book on RDBMS; you might want to start
with that. You are so completely off-base that a newsgroup cannot
really help you. The best we can do is throw out a kludge or try to do
your job for you.

--CELKO--
===========================
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are.

*** Sent via Developersdex http://www.developersdex.com ***
Re: multiple values Tom Moreau
8/16/2004 3:42:15 PM
You should have a separate table that contains all of the selected choices
for that item and have a foreign key to the "parent". Check out the
Northwind database and look at the foreign key relationship between [Order
Details] and Products.

--
Tom

---------------------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql


[quoted text, click to view]
Hi,

Does anyone has a some good advice/example how to store multiple values for
a field.

For single choice fields, i use a combobox in access and the value will be
an integer number, but how about when a field has multiple choices? Should i
use a listbox with multiple select enabled for visual appearance.
If i choose that option how should the value be stored? The sum of 2 or more
choices. But then again i will get stuck for example if a user chooses 2
choices with a value of 1 and 3. The sum of that is 4, but that could be the
value of choice option 4.

I'm running out of ideas, can anyone help me on this?

multiple values Ezekiël
8/16/2004 9:33:16 PM
Hi,

Does anyone has a some good advice/example how to store multiple values for
a field.

For single choice fields, i use a combobox in access and the value will be
an integer number, but how about when a field has multiple choices? Should i
use a listbox with multiple select enabled for visual appearance.
If i choose that option how should the value be stored? The sum of 2 or more
choices. But then again i will get stuck for example if a user chooses 2
choices with a value of 1 and 3. The sum of that is 4, but that could be the
value of choice option 4.

I'm running out of ideas, can anyone help me on this?

Re: multiple values David Portas
8/16/2004 9:57:29 PM
In a relational database each column in a table should hold only single,
atomic values. The solution to your problem is to get the correct table
design to start with. For example to represent Departments and Employees you
might use two tables related by a foreign key:

CREATE TABLE Departments (department_code CHAR(5) PRIMARY KEY,
department_name VARCHAR(20) NOT NULL UNIQUE)

CREATE TABLE Employees (ssn CHAR(10) PRIMARY KEY, employee_name VARCHAR(30)
NOT NULL, department_code CHAR(5) NOT NULL REFERENCES Departments
(department_code))

there is then no need to list all the employees in a column for each
department.

--
David Portas
SQL Server MVP
--

AddThis Social Bookmark Button