Click here to Skip to main content
15,353,726 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I work on sql server 2017 i have table data as below

i need to make design for data to be best practise and prevent repeating data

my issue here on column countries have data separated sticks so how to handle that

my key is company and year and rev and not repeated

so How to handle sticks on column countries

which design will be good for prevent sticks

What I have tried:

create table #countriesData
 (
 company int,
 [Year] int,
 rev  int,
 countries varchar(500)
 )
 insert into #countriesData(company,[Year],rev,countries)
 values
 (12011,2010,121,'Egypt|France|America'),
 (12011,2011,121,'Egypt|Canda|America'),
 (12011,2012,121,'China|Canda|America'),
 (12099,2010,121,'SaudiArabia|France|America'),
 (12099,2011,121,'Egypt|Canda|German'),
 (12099,2012,121, 'China|Italy|America')
Posted
Updated 22-May-22 21:58pm

1 solution

Create one table to hold the countries, each country should have a unique id
Create one table to old what ever this data is meant to be - without the countries column
Create a third table that links them together containing just the ids - each row links just one country to the id from this table, so each row in this table will have 3 rows on your linking table
   
Comments
ahmed_sa 23-May-22 5:56am
   
if i using checksum hasing will be good or not good to get every hash store as integer
CHill60 23-May-22 8:13am
   
What has checksum hashing got to do with this question - I don't understand what you are asking
Maciej Los 23-May-22 12:26pm
   
5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900