I have two tables in SQL Server 2012. I need to help with SQL query and also how should I model with UML ER diagram.
Requirements:
A) CustomerCode is primary key in Customer table. For example CustomerCode "12345" represent "Toyota Corporation".
B) There are several CustomerNameSynonum for each Customer Code.
C) There is CustomerCode for every single customers in Customer table, but not all customer have CustomerNameSynonyms.
Questions:
1) How should I set primary keys of CustomerNameSynonym table?
2) How should I set Forein Keys for these tables? (scripct will be usefull)
3) How should I model with UML ER diagram? (picture or hyperlink will be usefull)
CREATE TABLE [dbo].[Customer](
[CustomerCode] [nvarchar](50) NOT NULL,
[CustomerName] [nvarchar](100) NULL,
CONSTRAINT [PK_Compound] PRIMARY KEY CLUSTERED
(
[CompoundCode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
CREATE TABLE [dbo].[CustomerNameSynonym](
[CustomerCode] [nvarchar](50) NOT NULL,
[CustomerNameSynonym] [nvarchar](100) NULL
) ON [PRIMARY]
SELECT * FROM CustomerNameSynonym
12345, Toyota group
12345, Toyota Japan
12345, Toyota USA
22222, Nissan group
22222, Nissan Europe
Kenny_I