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

  • SEARCH
  • Home
  • 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 995457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:43:33+00:00 2026-05-16T06:43:33+00:00

I have 1 table with 6 columns lets call them A B C D

  • 0

I have 1 table with 6 columns lets call them
A B C D E F

They can be null or a value but that once have a value entered in any row of any column it must be null or unique and validated by the database
what key or constraint could I use to achive this?

ok real life scenario–
I have a product this is carrots the carrot can have upto 6 barcodes values, but if i have apples the barcode must not be the same any of the barcode values of carrots. Table columns product, barcode1, barcode2, barcode3, barcode4, barcode5, barcode6.

  • 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-05-16T06:43:33+00:00Added an answer on May 16, 2026 at 6:43 am

    If you are trying to enforce uniqueness across all six columns (e.g., I enter ‘Foo’ in column A for a row, then columns B,C,D,E, or F in that row cannot have ‘Foo’ nor any other row for columns A-F), there is no built-in mechanism to do this beyond triggers. I suspect that your data may not be normalized and that is likely the reason for the inability to use built-in referential mechanisms to enforce uniqueness. We would need to know more about the database schema to know for sure.

    ADDITION

    ok real life senario I have a product this is carrots the carrot can have upto 6 barcodes values, but if i have apples the barcode must not be the same any of the barcode values of carrots. Table columns product, barcode1, barcode2, barcode3, barcode4, barcode5, barcode6,

    The normalized solution would be to store your barcodes in another table:

    Create Table ProductBarCodes
    (
        ProductId ... not null References Products( Id )
        , Sequence int not null
        , Barcode ... not null
        , Constraint PK_ProductBarCodes Primary Key ( ProductId, Sequence )
        , Constraint CK_ProductBarCodes_Sequence Check ( Sequence Between 1 And 6 )
        , Constraint UC_ProductBarCodes_Barcode Unique ( Barcode )
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an sql table with some nvarchar columns, lets call them 'Title' and
Lets say I have table named Place with columns: placeId int not null auto_increment,
Lets say we have a database table with two columns, entry_time and value. entry_time
I have a city table that has two columns from_city to_city now lets assume
Basically, I have three tables, lets call them TableA, TableB and TableC. Table A
I have a table (lets call it main_guys) that looks like: id, other_item_id, other_item_type,
I have two tables (lets call them table A and B) both of them
Lets say I have a table with columns such as: ID Name City State
Lets say I have table with following columns 1. Client - string. 2. Profit
Lets say I have a table with the following columns: Qty, INTEGER SaleDate, DATETIME

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.