-
Notifications
You must be signed in to change notification settings - Fork 0
/
migrations_7.0.0.sql
2524 lines (2301 loc) · 168 KB
/
migrations_7.0.0.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
IF OBJECT_ID(N'[__EFMigrationsHistory]') IS NULL
BEGIN
CREATE TABLE [__EFMigrationsHistory] (
[MigrationId] nvarchar(150) NOT NULL,
[ProductVersion] nvarchar(32) NOT NULL,
CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId])
);
END;
GO
BEGIN TRANSACTION;
GO
IF SCHEMA_ID(N'Person') IS NULL EXEC(N'CREATE SCHEMA [Person];');
GO
IF SCHEMA_ID(N'Production') IS NULL EXEC(N'CREATE SCHEMA [Production];');
GO
IF SCHEMA_ID(N'Sales') IS NULL EXEC(N'CREATE SCHEMA [Sales];');
GO
IF SCHEMA_ID(N'HumanResources') IS NULL EXEC(N'CREATE SCHEMA [HumanResources];');
GO
IF SCHEMA_ID(N'Purchasing') IS NULL EXEC(N'CREATE SCHEMA [Purchasing];');
GO
CREATE TABLE [Person].[AddressType] (
[AddressTypeID] int NOT NULL IDENTITY,
[Name] nvarchar(50) NOT NULL,
[rowguid] uniqueidentifier NOT NULL DEFAULT ((newid())),
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_AddressType] PRIMARY KEY ([AddressTypeID])
);
DECLARE @description AS sql_variant;
SET @description = N'Types of addresses stored in the Address table. ';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'AddressType';
SET @description = N'Primary key for AddressType records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'AddressType', 'COLUMN', N'AddressTypeID';
SET @description = N'Address type description. For example, Billing, Home, or Shipping.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'AddressType', 'COLUMN', N'Name';
SET @description = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'AddressType', 'COLUMN', N'rowguid';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'AddressType', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [AWBuildVersion] (
[SystemInformationID] tinyint NOT NULL IDENTITY,
[Database Version] nvarchar(25) NOT NULL,
[VersionDate] datetime NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_AWBuildVersion_SystemInformationID] PRIMARY KEY ([SystemInformationID])
);
DECLARE @defaultSchema AS sysname;
SET @defaultSchema = SCHEMA_NAME();
DECLARE @description AS sql_variant;
SET @description = N'Current version number of the AdventureWorks 2016 sample database. ';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'AWBuildVersion';
SET @description = N'Primary key for AWBuildVersion records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'AWBuildVersion', 'COLUMN', N'SystemInformationID';
SET @description = N'Version number of the database in 9.yy.mm.dd.00 format.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'AWBuildVersion', 'COLUMN', N'Database Version';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'AWBuildVersion', 'COLUMN', N'VersionDate';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'AWBuildVersion', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Person].[BusinessEntity] (
[BusinessEntityID] int NOT NULL IDENTITY,
[rowguid] uniqueidentifier NOT NULL DEFAULT ((newid())),
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_BusinessEntity] PRIMARY KEY ([BusinessEntityID])
);
DECLARE @description AS sql_variant;
SET @description = N'Source of the ID that connects vendors, customers, and employees with address and contact information.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'BusinessEntity';
SET @description = N'Primary key for all customers, vendors, and employees.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'BusinessEntity', 'COLUMN', N'BusinessEntityID';
SET @description = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'BusinessEntity', 'COLUMN', N'rowguid';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'BusinessEntity', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Person].[ContactType] (
[ContactTypeID] int NOT NULL IDENTITY,
[Name] nvarchar(50) NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_ContactType] PRIMARY KEY ([ContactTypeID])
);
DECLARE @description AS sql_variant;
SET @description = N'Lookup table containing the types of business entity contacts.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'ContactType';
SET @description = N'Primary key for ContactType records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'ContactType', 'COLUMN', N'ContactTypeID';
SET @description = N'Contact type description.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'ContactType', 'COLUMN', N'Name';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'ContactType', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Person].[CountryRegion] (
[CountryRegionCode] nvarchar(3) NOT NULL,
[Name] nvarchar(50) NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_CountryRegion_CountryRegionCode] PRIMARY KEY ([CountryRegionCode])
);
DECLARE @description AS sql_variant;
SET @description = N'Lookup table containing the ISO standard codes for countries and regions.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'CountryRegion';
SET @description = N'ISO standard code for countries and regions.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'CountryRegion', 'COLUMN', N'CountryRegionCode';
SET @description = N'Country or region name.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'CountryRegion', 'COLUMN', N'Name';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'CountryRegion', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Sales].[CreditCard] (
[CreditCardID] int NOT NULL IDENTITY,
[CardType] nvarchar(50) NOT NULL,
[CardNumber] nvarchar(25) NOT NULL,
[ExpMonth] tinyint NOT NULL,
[ExpYear] smallint NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_CreditCard] PRIMARY KEY ([CreditCardID])
);
DECLARE @description AS sql_variant;
SET @description = N'Customer credit card information.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CreditCard';
SET @description = N'Primary key for CreditCard records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CreditCard', 'COLUMN', N'CreditCardID';
SET @description = N'Credit card name.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CreditCard', 'COLUMN', N'CardType';
SET @description = N'Credit card number.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CreditCard', 'COLUMN', N'CardNumber';
SET @description = N'Credit card expiration month.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CreditCard', 'COLUMN', N'ExpMonth';
SET @description = N'Credit card expiration year.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CreditCard', 'COLUMN', N'ExpYear';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CreditCard', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Production].[Culture] (
[CultureID] nchar(6) NOT NULL,
[Name] nvarchar(50) NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_Culture] PRIMARY KEY ([CultureID])
);
DECLARE @description AS sql_variant;
SET @description = N'Lookup table containing the languages in which some AdventureWorks data is stored.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'Culture';
SET @description = N'Primary key for Culture records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'Culture', 'COLUMN', N'CultureID';
SET @description = N'Culture description.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'Culture', 'COLUMN', N'Name';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'Culture', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Sales].[Currency] (
[CurrencyCode] nchar(3) NOT NULL,
[Name] nvarchar(50) NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_Currency_CurrencyCode] PRIMARY KEY ([CurrencyCode])
);
DECLARE @description AS sql_variant;
SET @description = N'Lookup table containing standard ISO currencies.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'Currency';
SET @description = N'The ISO code for the Currency.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'Currency', 'COLUMN', N'CurrencyCode';
SET @description = N'Currency name.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'Currency', 'COLUMN', N'Name';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'Currency', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [DatabaseLog] (
[DatabaseLogID] int NOT NULL IDENTITY,
[PostTime] datetime NOT NULL,
[DatabaseUser] nvarchar(128) NOT NULL,
[Event] nvarchar(128) NOT NULL,
[Schema] nvarchar(128) NULL,
[Object] nvarchar(128) NULL,
[TSQL] nvarchar(4000) NOT NULL,
[XmlEvent] nvarchar(4000) NOT NULL,
CONSTRAINT [PK_DatabaseLog_DatabaseLogID] PRIMARY KEY NONCLUSTERED ([DatabaseLogID])
);
DECLARE @defaultSchema AS sysname;
SET @defaultSchema = SCHEMA_NAME();
DECLARE @description AS sql_variant;
SET @description = N'Audit table tracking all DDL changes made to the AdventureWorks database. Data is captured by the database trigger ddlDatabaseTriggerLog.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'DatabaseLog';
SET @description = N'Primary key for DatabaseLog records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'DatabaseLog', 'COLUMN', N'DatabaseLogID';
SET @description = N'The date and time the DDL change occurred.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'DatabaseLog', 'COLUMN', N'PostTime';
SET @description = N'The user who implemented the DDL change.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'DatabaseLog', 'COLUMN', N'DatabaseUser';
SET @description = N'The type of DDL statement that was executed.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'DatabaseLog', 'COLUMN', N'Event';
SET @description = N'The schema to which the changed object belongs.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'DatabaseLog', 'COLUMN', N'Schema';
SET @description = N'The object that was changed by the DDL statment.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'DatabaseLog', 'COLUMN', N'Object';
SET @description = N'The exact Transact-SQL statement that was executed.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'DatabaseLog', 'COLUMN', N'TSQL';
SET @description = N'The raw XML data generated by database trigger.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'DatabaseLog', 'COLUMN', N'XmlEvent';
GO
CREATE TABLE [HumanResources].[Department] (
[DepartmentID] smallint NOT NULL IDENTITY,
[Name] nvarchar(50) NOT NULL,
[GroupName] nvarchar(50) NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_Department] PRIMARY KEY ([DepartmentID])
);
DECLARE @description AS sql_variant;
SET @description = N'Lookup table containing the departments within the Adventure Works Cycles company.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Department';
SET @description = N'Primary key for Department records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Department', 'COLUMN', N'DepartmentID';
SET @description = N'Name of the department.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Department', 'COLUMN', N'Name';
SET @description = N'Name of the group to which the department belongs.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Department', 'COLUMN', N'GroupName';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Department', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [ErrorLog] (
[ErrorLogID] int NOT NULL IDENTITY,
[ErrorTime] datetime NOT NULL DEFAULT ((getdate())),
[UserName] nvarchar(128) NOT NULL,
[ErrorNumber] int NOT NULL,
[ErrorSeverity] int NULL,
[ErrorState] int NULL,
[ErrorProcedure] nvarchar(126) NULL,
[ErrorLine] int NULL,
[ErrorMessage] nvarchar(4000) NOT NULL,
CONSTRAINT [PK_ErrorLog] PRIMARY KEY ([ErrorLogID])
);
DECLARE @defaultSchema AS sysname;
SET @defaultSchema = SCHEMA_NAME();
DECLARE @description AS sql_variant;
SET @description = N'Audit table tracking errors in the the AdventureWorks database that are caught by the CATCH block of a TRY...CATCH construct. Data is inserted by stored procedure dbo.uspLogError when it is executed from inside the CATCH block of a TRY...CATCH construct.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'ErrorLog';
SET @description = N'Primary key for ErrorLog records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'ErrorLog', 'COLUMN', N'ErrorLogID';
SET @description = N'The date and time at which the error occurred.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'ErrorLog', 'COLUMN', N'ErrorTime';
SET @description = N'The user who executed the batch in which the error occurred.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'ErrorLog', 'COLUMN', N'UserName';
SET @description = N'The error number of the error that occurred.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'ErrorLog', 'COLUMN', N'ErrorNumber';
SET @description = N'The severity of the error that occurred.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'ErrorLog', 'COLUMN', N'ErrorSeverity';
SET @description = N'The state number of the error that occurred.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'ErrorLog', 'COLUMN', N'ErrorState';
SET @description = N'The name of the stored procedure or trigger where the error occurred.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'ErrorLog', 'COLUMN', N'ErrorProcedure';
SET @description = N'The line number at which the error occurred.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'ErrorLog', 'COLUMN', N'ErrorLine';
SET @description = N'The message text of the error that occurred.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'ErrorLog', 'COLUMN', N'ErrorMessage';
GO
CREATE TABLE [Production].[Illustration] (
[IllustrationID] int NOT NULL IDENTITY,
[Diagram] nvarchar(4000) NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_Illustration] PRIMARY KEY ([IllustrationID])
);
DECLARE @description AS sql_variant;
SET @description = N'Bicycle assembly diagrams.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'Illustration';
SET @description = N'Primary key for Illustration records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'Illustration', 'COLUMN', N'IllustrationID';
SET @description = N'Illustrations used in manufacturing instructions. Stored as XML.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'Illustration', 'COLUMN', N'Diagram';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'Illustration', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Production].[Location] (
[LocationID] smallint NOT NULL IDENTITY,
[Name] nvarchar(50) NOT NULL,
[CostRate] smallmoney NOT NULL DEFAULT (((0.00))),
[Availability] decimal(8,2) NOT NULL DEFAULT (((0.00))),
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_Location] PRIMARY KEY ([LocationID])
);
DECLARE @description AS sql_variant;
SET @description = N'Product inventory and manufacturing locations.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'Location';
SET @description = N'Primary key for Location records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'Location', 'COLUMN', N'LocationID';
SET @description = N'Location description.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'Location', 'COLUMN', N'Name';
SET @description = N'Standard hourly cost of the manufacturing location.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'Location', 'COLUMN', N'CostRate';
SET @description = N'Work capacity (in hours) of the manufacturing location.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'Location', 'COLUMN', N'Availability';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'Location', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Person].[PhoneNumberType] (
[PhoneNumberTypeID] int NOT NULL IDENTITY,
[Name] nvarchar(50) NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_PhoneNumberType] PRIMARY KEY ([PhoneNumberTypeID])
);
DECLARE @description AS sql_variant;
SET @description = N'Type of phone number of a person.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'PhoneNumberType';
SET @description = N'Primary key for telephone number type records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'PhoneNumberType', 'COLUMN', N'PhoneNumberTypeID';
SET @description = N'Name of the telephone number type';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'PhoneNumberType', 'COLUMN', N'Name';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'PhoneNumberType', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Production].[ProductCategory] (
[ProductCategoryID] int NOT NULL IDENTITY,
[Name] nvarchar(50) NOT NULL,
[rowguid] uniqueidentifier NOT NULL DEFAULT ((newid())),
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_ProductCategory] PRIMARY KEY ([ProductCategoryID])
);
DECLARE @description AS sql_variant;
SET @description = N'High-level product categorization.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductCategory';
SET @description = N'Primary key for ProductCategory records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductCategory', 'COLUMN', N'ProductCategoryID';
SET @description = N'Category description.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductCategory', 'COLUMN', N'Name';
SET @description = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductCategory', 'COLUMN', N'rowguid';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductCategory', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Production].[ProductDescription] (
[ProductDescriptionID] int NOT NULL IDENTITY,
[Description] nvarchar(400) NOT NULL,
[rowguid] uniqueidentifier NOT NULL DEFAULT ((newid())),
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_ProductDescription] PRIMARY KEY ([ProductDescriptionID])
);
DECLARE @description AS sql_variant;
SET @description = N'Product descriptions in several languages.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductDescription';
SET @description = N'Primary key for ProductDescription records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductDescription', 'COLUMN', N'ProductDescriptionID';
SET @description = N'Description of the product.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductDescription', 'COLUMN', N'Description';
SET @description = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductDescription', 'COLUMN', N'rowguid';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductDescription', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Production].[ProductModel] (
[ProductModelID] int NOT NULL IDENTITY,
[Name] nvarchar(50) NOT NULL,
[CatalogDescription] nvarchar(4000) NULL,
[Instructions] nvarchar(4000) NULL,
[rowguid] uniqueidentifier NOT NULL DEFAULT ((newid())),
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_ProductModel] PRIMARY KEY ([ProductModelID])
);
DECLARE @description AS sql_variant;
SET @description = N'Product model classification.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductModel';
SET @description = N'Primary key for ProductModel records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductModel', 'COLUMN', N'ProductModelID';
SET @description = N'Product model description.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductModel', 'COLUMN', N'Name';
SET @description = N'Detailed product catalog information in xml format.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductModel', 'COLUMN', N'CatalogDescription';
SET @description = N'Manufacturing instructions in xml format.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductModel', 'COLUMN', N'Instructions';
SET @description = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductModel', 'COLUMN', N'rowguid';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductModel', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Production].[ProductPhoto] (
[ProductPhotoID] int NOT NULL IDENTITY,
[ThumbNailPhoto] varbinary(max) NULL,
[ThumbnailPhotoFileName] nvarchar(50) NULL,
[LargePhoto] varbinary(max) NULL,
[LargePhotoFileName] nvarchar(50) NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_ProductPhoto] PRIMARY KEY ([ProductPhotoID])
);
DECLARE @description AS sql_variant;
SET @description = N'Product images.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductPhoto';
SET @description = N'Primary key for ProductPhoto records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductPhoto', 'COLUMN', N'ProductPhotoID';
SET @description = N'Small image of the product.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductPhoto', 'COLUMN', N'ThumbNailPhoto';
SET @description = N'Small image file name.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductPhoto', 'COLUMN', N'ThumbnailPhotoFileName';
SET @description = N'Large image of the product.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductPhoto', 'COLUMN', N'LargePhoto';
SET @description = N'Large image file name.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductPhoto', 'COLUMN', N'LargePhotoFileName';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductPhoto', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Sales].[SalesReason] (
[SalesReasonID] int NOT NULL IDENTITY,
[Name] nvarchar(50) NOT NULL,
[ReasonType] nvarchar(50) NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_SalesReason] PRIMARY KEY ([SalesReasonID])
);
DECLARE @description AS sql_variant;
SET @description = N'Lookup table of customer purchase reasons.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SalesReason';
SET @description = N'Primary key for SalesReason records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SalesReason', 'COLUMN', N'SalesReasonID';
SET @description = N'Sales reason description.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SalesReason', 'COLUMN', N'Name';
SET @description = N'Category the sales reason belongs to.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SalesReason', 'COLUMN', N'ReasonType';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SalesReason', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Production].[ScrapReason] (
[ScrapReasonID] smallint NOT NULL IDENTITY,
[Name] nvarchar(50) NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_ScrapReason] PRIMARY KEY ([ScrapReasonID])
);
DECLARE @description AS sql_variant;
SET @description = N'Manufacturing failure reasons lookup table.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ScrapReason';
SET @description = N'Primary key for ScrapReason records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ScrapReason', 'COLUMN', N'ScrapReasonID';
SET @description = N'Failure description.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ScrapReason', 'COLUMN', N'Name';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ScrapReason', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [HumanResources].[Shift] (
[ShiftID] tinyint NOT NULL IDENTITY,
[Name] nvarchar(50) NOT NULL,
[StartTime] time NOT NULL,
[EndTime] time NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_Shift] PRIMARY KEY ([ShiftID])
);
DECLARE @description AS sql_variant;
SET @description = N'Work shift lookup table.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Shift';
SET @description = N'Primary key for Shift records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Shift', 'COLUMN', N'ShiftID';
SET @description = N'Shift description.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Shift', 'COLUMN', N'Name';
SET @description = N'Shift start time.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Shift', 'COLUMN', N'StartTime';
SET @description = N'Shift end time.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Shift', 'COLUMN', N'EndTime';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Shift', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Purchasing].[ShipMethod] (
[ShipMethodID] int NOT NULL IDENTITY,
[Name] nvarchar(50) NOT NULL,
[ShipBase] money NOT NULL DEFAULT (((0.00))),
[ShipRate] money NOT NULL DEFAULT (((0.00))),
[rowguid] uniqueidentifier NOT NULL DEFAULT ((newid())),
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_ShipMethod] PRIMARY KEY ([ShipMethodID])
);
DECLARE @description AS sql_variant;
SET @description = N'Shipping company lookup table.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Purchasing', 'TABLE', N'ShipMethod';
SET @description = N'Primary key for ShipMethod records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Purchasing', 'TABLE', N'ShipMethod', 'COLUMN', N'ShipMethodID';
SET @description = N'Shipping company name.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Purchasing', 'TABLE', N'ShipMethod', 'COLUMN', N'Name';
SET @description = N'Minimum shipping charge.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Purchasing', 'TABLE', N'ShipMethod', 'COLUMN', N'ShipBase';
SET @description = N'Shipping charge per pound.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Purchasing', 'TABLE', N'ShipMethod', 'COLUMN', N'ShipRate';
SET @description = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Purchasing', 'TABLE', N'ShipMethod', 'COLUMN', N'rowguid';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Purchasing', 'TABLE', N'ShipMethod', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Sales].[SpecialOffer] (
[SpecialOfferID] int NOT NULL IDENTITY,
[Description] nvarchar(255) NOT NULL,
[DiscountPct] smallmoney NOT NULL DEFAULT (((0.00))),
[Type] nvarchar(50) NOT NULL,
[Category] nvarchar(50) NOT NULL,
[StartDate] datetime NOT NULL,
[EndDate] datetime NOT NULL,
[MinQty] int NOT NULL,
[MaxQty] int NULL,
[rowguid] uniqueidentifier NOT NULL DEFAULT ((newid())),
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_SpecialOffer] PRIMARY KEY ([SpecialOfferID])
);
DECLARE @description AS sql_variant;
SET @description = N'Sale discounts lookup table.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SpecialOffer';
SET @description = N'Primary key for SpecialOffer records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SpecialOffer', 'COLUMN', N'SpecialOfferID';
SET @description = N'Discount description.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SpecialOffer', 'COLUMN', N'Description';
SET @description = N'Discount precentage.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SpecialOffer', 'COLUMN', N'DiscountPct';
SET @description = N'Discount type category.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SpecialOffer', 'COLUMN', N'Type';
SET @description = N'Group the discount applies to such as Reseller or Customer.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SpecialOffer', 'COLUMN', N'Category';
SET @description = N'Discount start date.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SpecialOffer', 'COLUMN', N'StartDate';
SET @description = N'Discount end date.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SpecialOffer', 'COLUMN', N'EndDate';
SET @description = N'Minimum discount percent allowed.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SpecialOffer', 'COLUMN', N'MinQty';
SET @description = N'Maximum discount percent allowed.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SpecialOffer', 'COLUMN', N'MaxQty';
SET @description = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SpecialOffer', 'COLUMN', N'rowguid';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SpecialOffer', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Production].[TransactionHistoryArchive] (
[TransactionID] int NOT NULL,
[ProductID] int NOT NULL,
[ReferenceOrderID] int NOT NULL,
[ReferenceOrderLineID] int NOT NULL,
[TransactionDate] datetime NOT NULL DEFAULT ((getdate())),
[TransactionType] nchar(1) NOT NULL,
[Quantity] int NOT NULL,
[ActualCost] money NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_TransactionHistoryArchive_TransactionID] PRIMARY KEY ([TransactionID])
);
DECLARE @description AS sql_variant;
SET @description = N'Transactions for previous years.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'TransactionHistoryArchive';
SET @description = N'Primary key for TransactionHistoryArchive records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'TransactionHistoryArchive', 'COLUMN', N'TransactionID';
SET @description = N'Product identification number. Foreign key to Product.ProductID.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'TransactionHistoryArchive', 'COLUMN', N'ProductID';
SET @description = N'Purchase order, sales order, or work order identification number.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'TransactionHistoryArchive', 'COLUMN', N'ReferenceOrderID';
SET @description = N'Line number associated with the purchase order, sales order, or work order.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'TransactionHistoryArchive', 'COLUMN', N'ReferenceOrderLineID';
SET @description = N'Date and time of the transaction.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'TransactionHistoryArchive', 'COLUMN', N'TransactionDate';
SET @description = N'W = Work Order, S = Sales Order, P = Purchase Order';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'TransactionHistoryArchive', 'COLUMN', N'TransactionType';
SET @description = N'Product quantity.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'TransactionHistoryArchive', 'COLUMN', N'Quantity';
SET @description = N'Product cost.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'TransactionHistoryArchive', 'COLUMN', N'ActualCost';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'TransactionHistoryArchive', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Production].[UnitMeasure] (
[UnitMeasureCode] nchar(3) NOT NULL,
[Name] nvarchar(50) NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_UnitMeasure_UnitMeasureCode] PRIMARY KEY ([UnitMeasureCode])
);
DECLARE @description AS sql_variant;
SET @description = N'Unit of measure lookup table.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'UnitMeasure';
SET @description = N'Primary key.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'UnitMeasure', 'COLUMN', N'UnitMeasureCode';
SET @description = N'Unit of measure description.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'UnitMeasure', 'COLUMN', N'Name';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'UnitMeasure', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Person].[Person] (
[BusinessEntityID] int NOT NULL,
[PersonType] nchar(2) NOT NULL,
[NameStyle] bit NOT NULL,
[Title] nvarchar(8) NULL,
[FirstName] nvarchar(50) NOT NULL,
[MiddleName] nvarchar(50) NULL,
[LastName] nvarchar(50) NOT NULL,
[Suffix] nvarchar(10) NULL,
[EmailPromotion] int NOT NULL,
[AdditionalContactInfo] nvarchar(4000) NULL,
[Demographics] nvarchar(4000) NULL,
[rowguid] uniqueidentifier NOT NULL DEFAULT ((newid())),
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_Person_BusinessEntityID] PRIMARY KEY ([BusinessEntityID]),
CONSTRAINT [FK_Person_BusinessEntity_BusinessEntityID] FOREIGN KEY ([BusinessEntityID]) REFERENCES [Person].[BusinessEntity] ([BusinessEntityID])
);
DECLARE @description AS sql_variant;
SET @description = N'Human beings involved with AdventureWorks: employees, customer contacts, and vendor contacts.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Person';
SET @description = N'Primary key for Person records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Person', 'COLUMN', N'BusinessEntityID';
SET @description = N'Primary type of person: SC = Store Contact, IN = Individual (retail) customer, SP = Sales person, EM = Employee (non-sales), VC = Vendor contact, GC = General contact';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Person', 'COLUMN', N'PersonType';
SET @description = N'0 = The data in FirstName and LastName are stored in western style (first name, last name) order. 1 = Eastern style (last name, first name) order.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Person', 'COLUMN', N'NameStyle';
SET @description = N'A courtesy title. For example, Mr. or Ms.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Person', 'COLUMN', N'Title';
SET @description = N'First name of the person.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Person', 'COLUMN', N'FirstName';
SET @description = N'Middle name or middle initial of the person.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Person', 'COLUMN', N'MiddleName';
SET @description = N'Last name of the person.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Person', 'COLUMN', N'LastName';
SET @description = N'Surname suffix. For example, Sr. or Jr.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Person', 'COLUMN', N'Suffix';
SET @description = N'0 = Contact does not wish to receive e-mail promotions, 1 = Contact does wish to receive e-mail promotions from AdventureWorks, 2 = Contact does wish to receive e-mail promotions from AdventureWorks and selected partners. ';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Person', 'COLUMN', N'EmailPromotion';
SET @description = N'Additional contact information about the person stored in xml format. ';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Person', 'COLUMN', N'AdditionalContactInfo';
SET @description = N'Personal information such as hobbies, and income collected from online shoppers. Used for sales analysis.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Person', 'COLUMN', N'Demographics';
SET @description = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Person', 'COLUMN', N'rowguid';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Person', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Purchasing].[Vendor] (
[BusinessEntityID] int NOT NULL,
[AccountNumber] nvarchar(15) NOT NULL,
[Name] nvarchar(50) NOT NULL,
[CreditRating] tinyint NOT NULL,
[PreferredVendorStatus] bit NOT NULL DEFAULT (((1))),
[ActiveFlag] bit NOT NULL DEFAULT (((1))),
[PurchasingWebServiceURL] nvarchar(1024) NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_Vendor_BusinessEntityID] PRIMARY KEY ([BusinessEntityID]),
CONSTRAINT [FK_Vendor_BusinessEntity_BusinessEntityID] FOREIGN KEY ([BusinessEntityID]) REFERENCES [Person].[BusinessEntity] ([BusinessEntityID])
);
DECLARE @description AS sql_variant;
SET @description = N'Companies from whom Adventure Works Cycles purchases parts or other goods.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Purchasing', 'TABLE', N'Vendor';
SET @description = N'Primary key for Vendor records. Foreign key to BusinessEntity.BusinessEntityID';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Purchasing', 'TABLE', N'Vendor', 'COLUMN', N'BusinessEntityID';
SET @description = N'Vendor account (identification) number.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Purchasing', 'TABLE', N'Vendor', 'COLUMN', N'AccountNumber';
SET @description = N'Company name.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Purchasing', 'TABLE', N'Vendor', 'COLUMN', N'Name';
SET @description = N'1 = Superior, 2 = Excellent, 3 = Above average, 4 = Average, 5 = Below average';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Purchasing', 'TABLE', N'Vendor', 'COLUMN', N'CreditRating';
SET @description = N'0 = Do not use if another vendor is available. 1 = Preferred over other vendors supplying the same product.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Purchasing', 'TABLE', N'Vendor', 'COLUMN', N'PreferredVendorStatus';
SET @description = N'0 = Vendor no longer used. 1 = Vendor is actively used.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Purchasing', 'TABLE', N'Vendor', 'COLUMN', N'ActiveFlag';
SET @description = N'Vendor URL.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Purchasing', 'TABLE', N'Vendor', 'COLUMN', N'PurchasingWebServiceURL';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Purchasing', 'TABLE', N'Vendor', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Sales].[SalesTerritory] (
[TerritoryID] int NOT NULL IDENTITY,
[Name] nvarchar(50) NOT NULL,
[CountryRegionCode] nvarchar(3) NOT NULL,
[Group] nvarchar(50) NOT NULL,
[SalesYTD] money NOT NULL DEFAULT (((0.00))),
[SalesLastYear] money NOT NULL DEFAULT (((0.00))),
[CostYTD] money NOT NULL DEFAULT (((0.00))),
[CostLastYear] money NOT NULL DEFAULT (((0.00))),
[rowguid] uniqueidentifier NOT NULL DEFAULT ((newid())),
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_SalesTerritory_TerritoryID] PRIMARY KEY ([TerritoryID]),
CONSTRAINT [FK_SalesTerritory_CountryRegion_CountryRegionCode] FOREIGN KEY ([CountryRegionCode]) REFERENCES [Person].[CountryRegion] ([CountryRegionCode])
);
DECLARE @description AS sql_variant;
SET @description = N'Sales territory lookup table.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritory';
SET @description = N'Primary key for SalesTerritory records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritory', 'COLUMN', N'TerritoryID';
SET @description = N'Sales territory description';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritory', 'COLUMN', N'Name';
SET @description = N'ISO standard country or region code. Foreign key to CountryRegion.CountryRegionCode. ';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritory', 'COLUMN', N'CountryRegionCode';
SET @description = N'Geographic area to which the sales territory belong.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritory', 'COLUMN', N'Group';
SET @description = N'Sales in the territory year to date.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritory', 'COLUMN', N'SalesYTD';
SET @description = N'Sales in the territory the previous year.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritory', 'COLUMN', N'SalesLastYear';
SET @description = N'Business costs in the territory year to date.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritory', 'COLUMN', N'CostYTD';
SET @description = N'Business costs in the territory the previous year.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritory', 'COLUMN', N'CostLastYear';
SET @description = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritory', 'COLUMN', N'rowguid';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritory', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Sales].[CountryRegionCurrency] (
[CountryRegionCode] nvarchar(3) NOT NULL,
[CurrencyCode] nchar(3) NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_CountryRegionCurrency_CountryRegionCode_CurrencyCode] PRIMARY KEY ([CountryRegionCode], [CurrencyCode]),
CONSTRAINT [FK_CountryRegionCurrency_CountryRegion_CountryRegionCode] FOREIGN KEY ([CountryRegionCode]) REFERENCES [Person].[CountryRegion] ([CountryRegionCode]),
CONSTRAINT [FK_CountryRegionCurrency_Currency_CurrencyCode] FOREIGN KEY ([CurrencyCode]) REFERENCES [Sales].[Currency] ([CurrencyCode])
);
DECLARE @description AS sql_variant;
SET @description = N'Cross-reference table mapping ISO currency codes to a country or region.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CountryRegionCurrency';
SET @description = N'ISO code for countries and regions. Foreign key to CountryRegion.CountryRegionCode.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CountryRegionCurrency', 'COLUMN', N'CountryRegionCode';
SET @description = N'ISO standard currency code. Foreign key to Currency.CurrencyCode.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CountryRegionCurrency', 'COLUMN', N'CurrencyCode';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CountryRegionCurrency', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Sales].[CurrencyRate] (
[CurrencyRateID] int NOT NULL IDENTITY,
[CurrencyRateDate] datetime NOT NULL,
[FromCurrencyCode] nchar(3) NOT NULL,
[ToCurrencyCode] nchar(3) NOT NULL,
[AverageRate] money NOT NULL,
[EndOfDayRate] money NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_CurrencyRate] PRIMARY KEY ([CurrencyRateID]),
CONSTRAINT [FK_CurrencyRate_Currency_FromCurrencyCode] FOREIGN KEY ([FromCurrencyCode]) REFERENCES [Sales].[Currency] ([CurrencyCode]),
CONSTRAINT [FK_CurrencyRate_Currency_ToCurrencyCode] FOREIGN KEY ([ToCurrencyCode]) REFERENCES [Sales].[Currency] ([CurrencyCode])
);
DECLARE @description AS sql_variant;
SET @description = N'Currency exchange rates.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CurrencyRate';
SET @description = N'Primary key for CurrencyRate records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CurrencyRate', 'COLUMN', N'CurrencyRateID';
SET @description = N'Date and time the exchange rate was obtained.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CurrencyRate', 'COLUMN', N'CurrencyRateDate';
SET @description = N'Exchange rate was converted from this currency code.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CurrencyRate', 'COLUMN', N'FromCurrencyCode';
SET @description = N'Exchange rate was converted to this currency code.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CurrencyRate', 'COLUMN', N'ToCurrencyCode';
SET @description = N'Average exchange rate for the day.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CurrencyRate', 'COLUMN', N'AverageRate';
SET @description = N'Final exchange rate for the day.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CurrencyRate', 'COLUMN', N'EndOfDayRate';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'CurrencyRate', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Production].[ProductSubcategory] (
[ProductSubcategoryID] int NOT NULL IDENTITY,
[ProductCategoryID] int NOT NULL,
[Name] nvarchar(50) NOT NULL,
[rowguid] uniqueidentifier NOT NULL DEFAULT ((newid())),
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_ProductSubcategory] PRIMARY KEY ([ProductSubcategoryID]),
CONSTRAINT [FK_ProductSubcategory_ProductCategory_ProductCategoryID] FOREIGN KEY ([ProductCategoryID]) REFERENCES [Production].[ProductCategory] ([ProductCategoryID])
);
DECLARE @description AS sql_variant;
SET @description = N'Product subcategories. See ProductCategory table.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductSubcategory';
SET @description = N'Primary key for ProductSubcategory records.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductSubcategory', 'COLUMN', N'ProductSubcategoryID';
SET @description = N'Product category identification number. Foreign key to ProductCategory.ProductCategoryID.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductSubcategory', 'COLUMN', N'ProductCategoryID';
SET @description = N'Subcategory description.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductSubcategory', 'COLUMN', N'Name';
SET @description = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductSubcategory', 'COLUMN', N'rowguid';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductSubcategory', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Production].[ProductModelIllustration] (
[ProductModelID] int NOT NULL,
[IllustrationID] int NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_ProductModelIllustration_ProductModelID_IllustrationID] PRIMARY KEY ([ProductModelID], [IllustrationID]),
CONSTRAINT [FK_ProductModelIllustration_Illustration_IllustrationID] FOREIGN KEY ([IllustrationID]) REFERENCES [Production].[Illustration] ([IllustrationID]),
CONSTRAINT [FK_ProductModelIllustration_ProductModel_ProductModelID] FOREIGN KEY ([ProductModelID]) REFERENCES [Production].[ProductModel] ([ProductModelID])
);
DECLARE @description AS sql_variant;
SET @description = N'Cross-reference table mapping product models and illustrations.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductModelIllustration';
SET @description = N'Primary key. Foreign key to ProductModel.ProductModelID.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductModelIllustration', 'COLUMN', N'ProductModelID';
SET @description = N'Primary key. Foreign key to Illustration.IllustrationID.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductModelIllustration', 'COLUMN', N'IllustrationID';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductModelIllustration', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Production].[ProductModelProductDescriptionCulture] (
[ProductModelID] int NOT NULL,
[ProductDescriptionID] int NOT NULL,
[CultureID] nchar(6) NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_ProductModelProductDescriptionCulture_ProductModelID_ProductDescriptionID_CultureID] PRIMARY KEY ([ProductModelID], [ProductDescriptionID], [CultureID]),
CONSTRAINT [FK_ProductModelProductDescriptionCulture_Culture_CultureID] FOREIGN KEY ([CultureID]) REFERENCES [Production].[Culture] ([CultureID]),
CONSTRAINT [FK_ProductModelProductDescriptionCulture_ProductDescription_ProductDescriptionID] FOREIGN KEY ([ProductDescriptionID]) REFERENCES [Production].[ProductDescription] ([ProductDescriptionID]),
CONSTRAINT [FK_ProductModelProductDescriptionCulture_ProductModel_ProductModelID] FOREIGN KEY ([ProductModelID]) REFERENCES [Production].[ProductModel] ([ProductModelID])
);
DECLARE @description AS sql_variant;
SET @description = N'Cross-reference table mapping product descriptions and the language the description is written in.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductModelProductDescriptionCulture';
SET @description = N'Primary key. Foreign key to ProductModel.ProductModelID.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductModelProductDescriptionCulture', 'COLUMN', N'ProductModelID';
SET @description = N'Primary key. Foreign key to ProductDescription.ProductDescriptionID.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductModelProductDescriptionCulture', 'COLUMN', N'ProductDescriptionID';
SET @description = N'Culture identification number. Foreign key to Culture.CultureID.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductModelProductDescriptionCulture', 'COLUMN', N'CultureID';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Production', 'TABLE', N'ProductModelProductDescriptionCulture', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Person].[BusinessEntityContact] (
[BusinessEntityID] int NOT NULL,
[PersonID] int NOT NULL,
[ContactTypeID] int NOT NULL,
[rowguid] uniqueidentifier NOT NULL DEFAULT ((newid())),
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_BusinessEntityContact_BusinessEntityID_PersonID_ContactTypeID] PRIMARY KEY ([BusinessEntityID], [PersonID], [ContactTypeID]),
CONSTRAINT [FK_BusinessEntityContact_BusinessEntity_BusinessEntityID] FOREIGN KEY ([BusinessEntityID]) REFERENCES [Person].[BusinessEntity] ([BusinessEntityID]),
CONSTRAINT [FK_BusinessEntityContact_ContactType_ContactTypeID] FOREIGN KEY ([ContactTypeID]) REFERENCES [Person].[ContactType] ([ContactTypeID]),
CONSTRAINT [FK_BusinessEntityContact_Person_PersonID] FOREIGN KEY ([PersonID]) REFERENCES [Person].[Person] ([BusinessEntityID])
);
DECLARE @description AS sql_variant;
SET @description = N'Cross-reference table mapping stores, vendors, and employees to people';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'BusinessEntityContact';
SET @description = N'Primary key. Foreign key to BusinessEntity.BusinessEntityID.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'BusinessEntityContact', 'COLUMN', N'BusinessEntityID';
SET @description = N'Primary key. Foreign key to Person.BusinessEntityID.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'BusinessEntityContact', 'COLUMN', N'PersonID';
SET @description = N'Primary key. Foreign key to ContactType.ContactTypeID.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'BusinessEntityContact', 'COLUMN', N'ContactTypeID';
SET @description = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'BusinessEntityContact', 'COLUMN', N'rowguid';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'BusinessEntityContact', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Person].[EmailAddress] (
[BusinessEntityID] int NOT NULL,
[EmailAddressID] int NOT NULL IDENTITY,
[EmailAddress] nvarchar(50) NULL,
[rowguid] uniqueidentifier NOT NULL DEFAULT ((newid())),
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_EmailAddress_BusinessEntityID_EmailAddressID] PRIMARY KEY ([BusinessEntityID], [EmailAddressID]),
CONSTRAINT [FK_EmailAddress_Person_BusinessEntityID] FOREIGN KEY ([BusinessEntityID]) REFERENCES [Person].[Person] ([BusinessEntityID])
);
DECLARE @description AS sql_variant;
SET @description = N'Where to send a person email.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'EmailAddress';
SET @description = N'Primary key. Person associated with this email address. Foreign key to Person.BusinessEntityID';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'EmailAddress', 'COLUMN', N'BusinessEntityID';
SET @description = N'Primary key. ID of this email address.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'EmailAddress', 'COLUMN', N'EmailAddressID';
SET @description = N'E-mail address for the person.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'EmailAddress', 'COLUMN', N'EmailAddress';
SET @description = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'EmailAddress', 'COLUMN', N'rowguid';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'EmailAddress', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [HumanResources].[Employee] (
[BusinessEntityID] int NOT NULL,
[NationalIDNumber] nvarchar(15) NOT NULL,
[LoginID] nvarchar(256) NOT NULL,
[OrganizationLevel] smallint NULL,
[JobTitle] nvarchar(50) NOT NULL,
[BirthDate] date NOT NULL,
[MaritalStatus] nchar(1) NOT NULL,
[Gender] nchar(1) NOT NULL,
[HireDate] date NOT NULL,
[SalariedFlag] bit NOT NULL DEFAULT (((1))),
[VacationHours] smallint NOT NULL,
[SickLeaveHours] smallint NOT NULL,
[CurrentFlag] bit NOT NULL DEFAULT (((1))),
[rowguid] uniqueidentifier NOT NULL DEFAULT ((newid())),
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_Employee_BusinessEntityID] PRIMARY KEY ([BusinessEntityID]),
CONSTRAINT [FK_Employee_Person_BusinessEntityID] FOREIGN KEY ([BusinessEntityID]) REFERENCES [Person].[Person] ([BusinessEntityID])
);
DECLARE @description AS sql_variant;
SET @description = N'Employee information such as salary, department, and title.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Employee';
SET @description = N'Primary key for Employee records. Foreign key to BusinessEntity.BusinessEntityID.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Employee', 'COLUMN', N'BusinessEntityID';
SET @description = N'Unique national identification number such as a social security number.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Employee', 'COLUMN', N'NationalIDNumber';
SET @description = N'Network login.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Employee', 'COLUMN', N'LoginID';
SET @description = N'The depth of the employee in the corporate hierarchy.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Employee', 'COLUMN', N'OrganizationLevel';
SET @description = N'Work title such as Buyer or Sales Representative.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Employee', 'COLUMN', N'JobTitle';
SET @description = N'Date of birth.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Employee', 'COLUMN', N'BirthDate';
SET @description = N'M = Married, S = Single';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Employee', 'COLUMN', N'MaritalStatus';
SET @description = N'M = Male, F = Female';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Employee', 'COLUMN', N'Gender';
SET @description = N'Employee hired on this date.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Employee', 'COLUMN', N'HireDate';
SET @description = N'Job classification. 0 = Hourly, not exempt from collective bargaining. 1 = Salaried, exempt from collective bargaining.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Employee', 'COLUMN', N'SalariedFlag';
SET @description = N'Number of available vacation hours.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Employee', 'COLUMN', N'VacationHours';
SET @description = N'Number of available sick leave hours.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Employee', 'COLUMN', N'SickLeaveHours';
SET @description = N'0 = Inactive, 1 = Active';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Employee', 'COLUMN', N'CurrentFlag';
SET @description = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Employee', 'COLUMN', N'rowguid';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'HumanResources', 'TABLE', N'Employee', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Person].[Password] (
[BusinessEntityID] int NOT NULL,
[PasswordHash] varchar(128) NOT NULL,
[PasswordSalt] varchar(10) NOT NULL,
[rowguid] uniqueidentifier NOT NULL DEFAULT ((newid())),
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_Password_BusinessEntityID] PRIMARY KEY ([BusinessEntityID]),
CONSTRAINT [FK_Password_Person_BusinessEntityID] FOREIGN KEY ([BusinessEntityID]) REFERENCES [Person].[Person] ([BusinessEntityID])
);
DECLARE @description AS sql_variant;
SET @description = N'One way hashed authentication information';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Password';
SET @description = N'Password for the e-mail account.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Password', 'COLUMN', N'PasswordHash';
SET @description = N'Random value concatenated with the password string before the password is hashed.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Password', 'COLUMN', N'PasswordSalt';
SET @description = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Password', 'COLUMN', N'rowguid';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'Password', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Sales].[PersonCreditCard] (
[BusinessEntityID] int NOT NULL,
[CreditCardID] int NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_PersonCreditCard_BusinessEntityID_CreditCardID] PRIMARY KEY ([BusinessEntityID], [CreditCardID]),
CONSTRAINT [FK_PersonCreditCard_CreditCard_CreditCardID] FOREIGN KEY ([CreditCardID]) REFERENCES [Sales].[CreditCard] ([CreditCardID]),
CONSTRAINT [FK_PersonCreditCard_Person_BusinessEntityID] FOREIGN KEY ([BusinessEntityID]) REFERENCES [Person].[Person] ([BusinessEntityID])
);
DECLARE @description AS sql_variant;
SET @description = N'Cross-reference table mapping people to their credit card information in the CreditCard table. ';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'PersonCreditCard';
SET @description = N'Business entity identification number. Foreign key to Person.BusinessEntityID.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'PersonCreditCard', 'COLUMN', N'BusinessEntityID';
SET @description = N'Credit card identification number. Foreign key to CreditCard.CreditCardID.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'PersonCreditCard', 'COLUMN', N'CreditCardID';
SET @description = N'Date and time the record was last updated.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Sales', 'TABLE', N'PersonCreditCard', 'COLUMN', N'ModifiedDate';
GO
CREATE TABLE [Person].[PersonPhone] (
[BusinessEntityID] int NOT NULL,
[PhoneNumber] nvarchar(25) NOT NULL,
[PhoneNumberTypeID] int NOT NULL,
[ModifiedDate] datetime NOT NULL DEFAULT ((getdate())),
CONSTRAINT [PK_PersonPhone_BusinessEntityID_PhoneNumber_PhoneNumberTypeID] PRIMARY KEY ([BusinessEntityID], [PhoneNumber], [PhoneNumberTypeID]),
CONSTRAINT [FK_PersonPhone_Person_BusinessEntityID] FOREIGN KEY ([BusinessEntityID]) REFERENCES [Person].[Person] ([BusinessEntityID]),
CONSTRAINT [FK_PersonPhone_PhoneNumberType_PhoneNumberTypeID] FOREIGN KEY ([PhoneNumberTypeID]) REFERENCES [Person].[PhoneNumberType] ([PhoneNumberTypeID])
);
DECLARE @description AS sql_variant;
SET @description = N'Telephone number and type of a person.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'PersonPhone';
SET @description = N'Business entity identification number. Foreign key to Person.BusinessEntityID.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'PersonPhone', 'COLUMN', N'BusinessEntityID';
SET @description = N'Telephone number identification number.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'PersonPhone', 'COLUMN', N'PhoneNumber';
SET @description = N'Kind of phone number. Foreign key to PhoneNumberType.PhoneNumberTypeID.';
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', N'Person', 'TABLE', N'PersonPhone', 'COLUMN', N'PhoneNumberTypeID';
SET @description = N'Date and time the record was last updated.';