Hi
I have proble to figure up how create databaze schema for text localization. My problem is like i have table with Towns and i need to localizate it to diferent language. Something like London - Londin and so on.
Problem:
The problem is that i cant create FK to a not PK. Because localization table will have more records (depends on languages) to that one FK.
Qustion:
Is it posible to make unique double key (in our case "ZDROJ, JAZYK_ID") like PK and use it in FK->PK?
Thanks for any help ;) im new to web developing and mssql.
Sorry for my language im from Slovakia :).
I try to create two tables like this :
first table is connectin table with CINNOSTI (like Sauna, fitnes ....), it should with CINNOST_ENUM_RES connect to table name ZDROJE where are the localizations strings for this table and others tables.
/****** Object: Table [dbo].[CINNOST] Script Date: 09/09/2009 10:57:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[CINNOST](
[CINNOST_ENUM_RES] [varchar](20) NOT NULL,
[ID] [int] IDENTITY(0,1) NOT NULL,
CONSTRAINT [PK_CINNOST] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
CONSTRAINT [UQ_CINNOST_ID] UNIQUE NONCLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
the second table contain the language localization
/****** Object: Table [dbo].[ZDROJE] Script Date: 09/09/2009 11:03:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ZDROJE](
[ID] [int] IDENTITY(0,1) NOT NULL,
[ZDROJ] [varchar](20) NOT NULL,
[TEXT_LOC] [nvarchar](1000) NOT NULL,
[LANGUAGE_ID] [int] NOT NULL,
CONSTRAINT [PK_RESOURCES] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
CONSTRAINT [UQ_RESOURCES_ID] UNIQUE NONCLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[ZDROJE] WITH CHECK ADD CONSTRAINT [FK_RESOURCES_LANGUAGE] FOREIGN KEY([LANGUAGE_ID])
REFERENCES [dbo].[JAZYK] ([ID])
GO
ALTER TABLE [dbo].[ZDROJE] CHECK CONSTRAINT [FK_RESOURCES_LANGUAGE]
GO
this table just consist languages
/****** Object: Table [dbo].[JAZYK] Script Date: 09/09/2009 11:09:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JAZYK](
[ID] [int] IDENTITY(0,1) NOT NULL,
[NAME] [nvarchar](100) NOT NULL,
[LCODE] [varchar](10) NOT NULL,
CONSTRAINT [PK_LANGUAGE] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
CONSTRAINT [UQ_LANGUAGE_CODE] UNIQUE NONCLUSTERED
(
[LCODE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
CONSTRAINT [UQ_LANGUAGE_ID] UNIQUE NONCLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
CONSTRAINT [UQ_LANGUAGE_NAME] UNIQUE NONCLUSTERED
(
[NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO