-
Notifications
You must be signed in to change notification settings - Fork 0
/
3.ReformatTables.example.txt
30 lines (27 loc) · 1.11 KB
/
3.ReformatTables.example.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
CREATE TABLE [dbo].[AttributeType](
[Id] [int] IDENTITY(1,1) NOT NULL
,[Name] [nvarchar](50) NOT NULL
,CONSTRAINT [PK_AttributeType] PRIMARY KEY CLUSTERED (Id)
);
CREATE TABLE [dbo].[Attribute](
[Id] [int] IDENTITY(1,1) NOT NULL
,[Name] [nvarchar](50) NOT NULL
,[Description] [nvarchar](max) NULL
,[AttributeTypeId] [int] NOT NULL
,CONSTRAINT [PK_Attribute] PRIMARY KEY CLUSTERED (Id)
,CONSTRAINT [FK_Attribute_AttributeType_AttributeTypeId] FOREIGN KEY (AttributeTypeId) REFERENCES [dbo].[AttributeType](Id)
);
CREATE TABLE [dbo].[Person](
[Id] [int] IDENTITY(1,1) NOT NULL
,[GivenName] [nvarchar](50) NOT NULL
,[FamilyName] [nvarchar](50) NOT NULL
,CONSTRAINT [PK_Person] PRIMARY KEY CLUSTERED (Id)
);
CREATE TABLE [dbo].[PersonAttribute](
[Id] [int] IDENTITY(1,1) NOT NULL
,[PersonId] [int] NOT NULL
,[AttributeId] [int] NOT NULL
,CONSTRAINT [PK_PersonAttribute] PRIMARY KEY CLUSTERED (Id)
,CONSTRAINT [FK_PersonAttribute_Person_PersonId] FOREIGN KEY (PersonId) REFERENCES [dbo].[Person](Id)
,CONSTRAINT [FK_PersonAttribute_Attribute_AttributeId] FOREIGN KEY (AttributeId) REFERENCES [dbo].[Attribute](Id)
);