I have a language table 'CDE_LANGUAGE' where we defines languages.
CREATE TABLE [dbo].[CDE_LANGUAGE] (
[language_id] [smallint] NT NULL PRIMARY KEY CLUSTERED,
[language_name] [varchar(20)] NT NULL
) N [PRIMARY]
G
An example of data in this table is:
language_id language_name
1 USA English
2 CAN English
3 French
4 Spanish
I need to design a table for Location codes "CDE_LCATIN". This table need
to have these attributes:
location_id
location_name
location_desc
active_flag
external_value
Problem is that for each location the Location Description (location_desc)
can be in any Language we supported. So if there is a Location 'Mississauga'
and we have four Languages in the System (USA English, CAN English, French
and Spanish), then there will be four location_desc for Mississauga.
So what would be the best way to resolve this problem?
I can think of two solutions:
Solution1:
Add 2 columns in 'CDE_LCATIN' table: "id" column and "language_id"
column. The "id" column will be an identity column and will be the primary
key. The "language_id" column will be foreign key to "language_id" column in
'CDE_LANGUAGE' table.
CREATE TABLE [dbo].[CDE_LCATIN] (
[id] [int] IDENTITY (1, 1) NT NULL PRIMARY KEY CLUSTERED,
[location_id] [smallint] NT NULL ,
[location_name] [varchar(20)] NT NULL ,
[language_id] [smallint] NT NULL,
[location_desc] [varchar(255)] NT NULL ,
[active_flag] [tinyint] NT NULL ,
[external_value] [varchar(10)] NULL
) N [PRIMARY]
G
Solution2:
Create a seperate table "LANGUAGE_LCATIN" which stores description of
location codes in different languages. Its primary key will be foreign key
in 'CDE_LCATIN' table.
CREATE TABLE [dbo].[LANGUAGE_LCATIN] (
[lang_loc_id] [int] IDENTITY (1, 1) NT NULL PRIMARY KEY CLUSTERED,
[language_id] [smallint] NT NULL ,
[location_id] [smallint] NT NULL ,
[location_desc] [varchar(255)] NT NULL
) N [PRIMARY]
G
CREATE TABLE [dbo].[CDE_LCATIN] (
[location_id] [smallint] NT NULL PRIMARY KEY CLUSTERED,
[location_name] [varchar(20)] NT NULL ,
[lang_loc_id] [int] NT NULL REFERENCES LANGUAGE_LCATIN(lang_loc_id),
[active_flag] [tinyint] NT NULL ,
[external_value] [varchar(10)] NULL
) N [PRIMARY]
G
Which solution is better and why?
It is my understanding that both solutions are in 3rd normal form. Is it
correct?
Do you guys have any better solution?
Thanks