Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2011
    Posts
    10

    Unanswered: Multiple values in one attribute?

    Hi
    I know an attribute can only have one value. If for instance a customer in CUSTOMER table has more than one address or telephone number, how I can determine it before defining the attribute of the entity type? What would the source code of it be?
    Code:
    CREATE TABLE CUSTOMER
    (
    C_Id CHAR(10),
    Name VARCHAR,
    Tel_No VARCHAR /*how should I do it? */
    );
    INSERT INTO CUSTOMER
    VALUES (
    	'a12',
    	'Middin',
    	'09182343543 and 033334548934 how should I do it?'
    	)

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Storing multiple values in a single column is considered bad DB design.

    However if you really want to do it, you can use an array datatype:
    Code:
    CREATE TABLE customer
    (
       C_Id   VARCHAR(10),
       Name   VARCHAR,
       Tel_No VARCHAR[]
    );
    
    INSERT INTO CUSTOMER
    (c_id, name, tel_no)
    VALUES 
    (	'a12',
    	'Middin',
    	ARRAY ['09182343543','033334548934']
    )
    Note that you do not want CHAR(10) unless your values are always exactly 10 characters long.

  3. #3
    Join Date
    Dec 2011
    Posts
    10
    Thank you
    In fact it cause me a lot of difficulty, but I have do deal with it.

Posting Permissions

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