-
Notifications
You must be signed in to change notification settings - Fork 0
/
APMACMaintanceEntity.edmx.sql
176 lines (148 loc) · 5.17 KB
/
APMACMaintanceEntity.edmx.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 02/17/2014 13:49:33
-- Generated from EDMX file: D:\KRUNAL\PErsonal\APM_AC\APM_AC\DB_Access\APMACMaintanceEntity.edmx
-- --------------------------------------------------
SET QUOTED_IDENTIFIER OFF;
GO
USE [APM_ACMaintance];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO
-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------
-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------
-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------
-- Creating table 'ACMasters'
CREATE TABLE [dbo].[ACMasters] (
[Id] int IDENTITY(1,1) NOT NULL,
[ACTypeMasterId] int NOT NULL,
[PurchaseDate] datetime NULL,
[LastServiceDate] datetime NULL,
[Note] nvarchar(max) NOT NULL,
[LocationMasterId] int NOT NULL
);
GO
-- Creating table 'ACTypeMasters'
CREATE TABLE [dbo].[ACTypeMasters] (
[Id] int IDENTITY(1,1) NOT NULL,
[ACName] nvarchar(max) NOT NULL,
[ACCompanyName] nvarchar(max) NOT NULL,
[Tons] decimal(18,0) NOT NULL
);
GO
-- Creating table 'LocationMasters'
CREATE TABLE [dbo].[LocationMasters] (
[Id] int IDENTITY(1,1) NOT NULL,
[AddLine1] nvarchar(max) NULL,
[AddLine2] nvarchar(max) NULL,
[AddLine3] nvarchar(max) NULL
);
GO
-- Creating table 'PersonMasters'
CREATE TABLE [dbo].[PersonMasters] (
[Id] int IDENTITY(1,1) NOT NULL,
[Name] nvarchar(max) NOT NULL,
[Mobile] nvarchar(max) NULL,
[Address] nvarchar(max) NULL,
[DOJ] datetime NULL,
[DOB] datetime NULL
);
GO
-- Creating table 'ACServiceHistories'
CREATE TABLE [dbo].[ACServiceHistories] (
[Id] int IDENTITY(1,1) NOT NULL,
[ServiceDate] datetime NOT NULL,
[Note] nvarchar(max) NULL,
[PersonMasterId] int NOT NULL,
[ACMasterId] int NOT NULL
);
GO
-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------
-- Creating primary key on [Id] in table 'ACMasters'
ALTER TABLE [dbo].[ACMasters]
ADD CONSTRAINT [PK_ACMasters]
PRIMARY KEY CLUSTERED ([Id] ASC);
GO
-- Creating primary key on [Id] in table 'ACTypeMasters'
ALTER TABLE [dbo].[ACTypeMasters]
ADD CONSTRAINT [PK_ACTypeMasters]
PRIMARY KEY CLUSTERED ([Id] ASC);
GO
-- Creating primary key on [Id] in table 'LocationMasters'
ALTER TABLE [dbo].[LocationMasters]
ADD CONSTRAINT [PK_LocationMasters]
PRIMARY KEY CLUSTERED ([Id] ASC);
GO
-- Creating primary key on [Id] in table 'PersonMasters'
ALTER TABLE [dbo].[PersonMasters]
ADD CONSTRAINT [PK_PersonMasters]
PRIMARY KEY CLUSTERED ([Id] ASC);
GO
-- Creating primary key on [Id] in table 'ACServiceHistories'
ALTER TABLE [dbo].[ACServiceHistories]
ADD CONSTRAINT [PK_ACServiceHistories]
PRIMARY KEY CLUSTERED ([Id] ASC);
GO
-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------
-- Creating foreign key on [ACTypeMasterId] in table 'ACMasters'
ALTER TABLE [dbo].[ACMasters]
ADD CONSTRAINT [FK_ACTypeMasterACMaster]
FOREIGN KEY ([ACTypeMasterId])
REFERENCES [dbo].[ACTypeMasters]
([Id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_ACTypeMasterACMaster'
CREATE INDEX [IX_FK_ACTypeMasterACMaster]
ON [dbo].[ACMasters]
([ACTypeMasterId]);
GO
-- Creating foreign key on [LocationMasterId] in table 'ACMasters'
ALTER TABLE [dbo].[ACMasters]
ADD CONSTRAINT [FK_LocationMasterACMaster]
FOREIGN KEY ([LocationMasterId])
REFERENCES [dbo].[LocationMasters]
([Id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_LocationMasterACMaster'
CREATE INDEX [IX_FK_LocationMasterACMaster]
ON [dbo].[ACMasters]
([LocationMasterId]);
GO
-- Creating foreign key on [PersonMasterId] in table 'ACServiceHistories'
ALTER TABLE [dbo].[ACServiceHistories]
ADD CONSTRAINT [FK_PersonMasterACServiceHistory]
FOREIGN KEY ([PersonMasterId])
REFERENCES [dbo].[PersonMasters]
([Id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_PersonMasterACServiceHistory'
CREATE INDEX [IX_FK_PersonMasterACServiceHistory]
ON [dbo].[ACServiceHistories]
([PersonMasterId]);
GO
-- Creating foreign key on [ACMasterId] in table 'ACServiceHistories'
ALTER TABLE [dbo].[ACServiceHistories]
ADD CONSTRAINT [FK_ACMasterACServiceHistory]
FOREIGN KEY ([ACMasterId])
REFERENCES [dbo].[ACMasters]
([Id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_ACMasterACServiceHistory'
CREATE INDEX [IX_FK_ACMasterACServiceHistory]
ON [dbo].[ACServiceHistories]
([ACMasterId]);
GO
-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------