-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1.CreateToDropTable.example.txt
More file actions
30 lines (27 loc) · 1.02 KB
/
1.CreateToDropTable.example.txt
File metadata and controls
30 lines (27 loc) · 1.02 KB
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(11) NOT NULL,
Name nvarchar(50) NOT NULL,
CONSTRAINT PK_AttributeType PRIMARY KEY CLUSTERED (Id),
);
CREATE TABLE dbo.Attribute(
Id int IDENTITY(11) 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(11) 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(11) 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),
);