-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEntitiesConnection(2015-05-16 09-30-55).rlinq.sql
54 lines (44 loc) · 1.62 KB
/
EntitiesConnection(2015-05-16 09-30-55).rlinq.sql
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
-- TinyMapperTests.Person
CREATE TABLE [Person] (
[TypeID] int NOT NULL, -- _personType
[name] varchar(255) NULL, -- _name
[Id] int NOT NULL, -- _id
CONSTRAINT [pk_Person] PRIMARY KEY ([Id])
)
go
-- TinyMapperTests.Contact
CREATE TABLE [contact] (
[phone] varchar(255) NULL, -- _phone
[person_i_d] int NOT NULL, -- _person
[id] int NOT NULL, -- _id
[type_i_d] int NOT NULL, -- _contactType
[address] varchar(255) NULL, -- _address
CONSTRAINT [pk_contact] PRIMARY KEY ([id])
)
go
-- TinyMapperTests.ContactType
CREATE TABLE [contact_type] (
[id] int NOT NULL, -- _id
[description] varchar(255) NULL, -- _description
CONSTRAINT [pk_contact_type] PRIMARY KEY ([id])
)
go
-- TinyMapperTests.PersonType
CREATE TABLE [person_type] (
[id] int NOT NULL, -- _id
[description] varchar(255) NULL, -- _description
CONSTRAINT [pk_person_type] PRIMARY KEY ([id])
)
go
CREATE INDEX [idx_Person_TypeID] ON [Person]([TypeID])
go
CREATE INDEX [idx_contact_type_i_d] ON [contact]([type_i_d])
go
CREATE INDEX [idx_contact_person_i_d] ON [contact]([person_i_d])
go
ALTER TABLE [Person] ADD CONSTRAINT [ref_Person_person_type] FOREIGN KEY ([TypeID]) REFERENCES [person_type]([id])
go
ALTER TABLE [contact] ADD CONSTRAINT [ref_contact_contact_type] FOREIGN KEY ([type_i_d]) REFERENCES [contact_type]([id])
go
ALTER TABLE [contact] ADD CONSTRAINT [ref_contact_Person] FOREIGN KEY ([person_i_d]) REFERENCES [Person]([Id])
go