Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9008385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:55:34+00:00 2026-06-16T01:55:34+00:00

I have one column in my table that can store one value or two

  • 0

I have one column in my table that can store one value or two value at one record.

For example I have a table for users that they can store one or two address. Notice, they can’t store more than two address, it’s limit.

I have 2 way in my mind:

1- Set two column in my table for two value.
2- Create another table for 2nd value.

I need help to find best way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:55:36+00:00Added an answer on June 16, 2026 at 1:55 am

    1- Set two column in my table for two value. 2- Create another table for 2nd value.

    It depends on your actual data. First of all, you should get a basic understanding of database design principles and normalization. Normalization is primarily to save space and help ensuring data consistency.

    For your concrete issue: You say that you have two values and that one record can either store one or two of them.
    Lets assume the value is a primitive type like INT. In this case, I would go with one table having two columns:

    CREATE TABLE dataTable (
        first INT NOT NULL,
        second INT
    );
    

    This table can store one number (first) and an optional second number. I omitted a primary key which, in reality, you should add.

    Now, you say that you want to store addresses. An address is not a primitive type, since it is usually composed of first name, last name, street, zip code, city, and depending on your location some additional information.

    Again, the straight forward way would be to simply create one table with two sets of these data:

    CREATE TABLE dataTable (
        firstName VARCHAR(40),
        lastName VARCHAR(40),
        street VARCHAR(40),
        zipCode INT,
        firstName2 VARCHAR(40),
        lastName2 VARCHAR(40),
        street2 VARCHAR(40),
        zipCode2 INT
    );
    

    However, this approach is unflexible and might also waste space. In this case, I would separate (“normalize”) the schema and use two tables:

    CREATE TABLE address (
        id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
        firstName VARCHAR(40),
        lastName VARCHAR(40),
        street VARCHAR(40),
        zipCode INT
    );
    
    CREATE TABLE dataTable (
        first INT NOT NULL,
        second INT,
        FOREIGN KEY (first) REFERENCES address(id),
        FOREIGN KEY (second) REFERENCES address(id)
    );
    

    With this approach, you can store (“reference”) either one or two addresses in your data table. The drawback is, of course, that you need to insert data into two tables when creating a new record, and that you need to properly join the tables in your queries. However, it allows you for example to add additional constraints, e.g. to define that a first name is optional, but a last name is mandatory (“NOT NULL”). This would not be possible with the first approach, since you could not distinguish between the whole (second) address being optional or only the first name being optional.

    notice they can’t store more than two address,It’s limit.

    Well – yes, until your customer comes back and needs to store three 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TABLE elements with one COLUMN number, type SMALLINT that contains numbers
I have a table that has two datetime columns (one for start time and
I have a table that containts a set of columns one of it is
I have one datatable. In that table I have columns named [Total Day], [Present
Screenshot mockup: http://tinypic.com/r/y2qex/5 Problem: I have a table that has 53 columns; one for
I Have a table in my databse that one of the columns named NumOfView
I have a table of 3-4 columns, the central one being task names that
by default I have one column in MySQL table to be NULL. I want
I have data table containing one column as FilePath. FilePath D:\New folder\link.txt D:\New folder\SharepointMigration(Work
I have a table with one column and four rows. Each tr has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.