· 5 years ago · Oct 26, 2020, 10:58 AM
1--
2-- CAREFUL!!
3-- DB Tables called Templates, Blocks and TemplatesBlocks will be DROPPED
4--
5
6--
7-- Templates table and data --
8DROP TABLE IF EXISTS Templates;
9CREATE TABLE [dbo].[Templates](
10 [id] [int] IDENTITY(1,1) NOT NULL,
11 [name] [nvarchar](60) NOT NULL,
12 [notetype] [nvarchar](10) NULL,
13 [page] [nvarchar](100) NULL,
14 [disabled] [bit] NULL,
15 CONSTRAINT [PK_Templates_id] PRIMARY KEY CLUSTERED([id] ASC)
16)
17GO
18
19INSERT INTO [dbo].[Templates]([name], [notetype], [page], [disabled])
20VALUES
21 ('TEST', 'ALL', 'Something', 0),
22 ('Wassname', 'ALL', 'SomePage', 0),
23 ('Coolaid Template', 'ALL', 'page 4', 0)
24GO
25
26
27--
28-- Blocks Table and data --
29DROP TABLE IF EXISTS Blocks;
30CREATE TABLE [dbo].[Blocks](
31 [id] [int] IDENTITY(1,1) NOT NULL,
32 [name] [nvarchar](60) NOT NULL,
33 [code] [nvarchar](25) NULL,
34 [disabled] [bit] NULL,
35 CONSTRAINT [PK_Blocks_id] PRIMARY KEY CLUSTERED([id] ASC)
36)
37GO
38
39INSERT INTO [dbo].[Blocks]([name], [code], [disabled])
40VALUES
41 ('Personal Details', 'personal_details', 0),
42 ('Contact Details', 'contact_details', 0),
43 ('Address Details', 'address_details', 0),
44 ('Other Details', 'other_details', 0),
45 ('Some Details', 'some_details', 0)
46GO
47
48
49--
50-- Join table TemplateBlocks --
51DROP TABLE IF EXISTS [TemplatesBlocks];
52CREATE TABLE [dbo].[TemplatesBlocks](
53 [id] [int] IDENTITY(1,1) NOT NULL,
54 [Template_id] [int] NOT NULL,
55 [Block_id] [int] NOT NULL
56) ON [PRIMARY]
57GO
58
59INSERT INTO TemplatesBlocks (Template_id, Block_id)
60VALUES
61(3, 1),
62(3, 4),
63(2, 1),
64(1, 1),
65(2, 2);
66
67
68
69Select * From Templates;
70select * From Blocks;
71Select * From TemplatesBlocks;
72
73