- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
CREATE TABLE [Battles] (
[name] [varchar] (20) NOT NULL ,
[date] [datetime] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [Classes] (
[class] [varchar] (50) NOT NULL ,
[type] [varchar] (2) NOT NULL ,
[country] [varchar] (20) NOT NULL ,
[numGuns] [tinyint] NULL ,
[bore] [real] NULL ,
[displacement] [int] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[Ships] (
[name] [varchar] (50) NOT NULL ,
[class] [varchar] (50) NOT NULL ,
[launched] [smallint] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[Outcomes] (
[ship] [varchar] (50) NOT NULL ,
[battle] [varchar] (20) NOT NULL ,
[result] [varchar] (10) NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Battles] ADD
CONSTRAINT [PK_Battles] PRIMARY KEY CLUSTERED
(
[name]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Classes] ADD
CONSTRAINT [PK_Classes] PRIMARY KEY CLUSTERED
(
[class]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Ships] ADD
CONSTRAINT [PK_Ships] PRIMARY KEY CLUSTERED
(
[name]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Outcomes] ADD
CONSTRAINT [PK_Outcomes] PRIMARY KEY CLUSTERED
(
[ship],
[battle]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Ships] ADD
CONSTRAINT [FK_Ships_Classes] FOREIGN KEY
(
[class]
) REFERENCES [dbo].[Classes] (
[class]
) NOT FOR REPLICATION
GO
ALTER TABLE [dbo].[Outcomes] ADD
CONSTRAINT [FK_Outcomes_Battles] FOREIGN KEY
(
[battle]
) REFERENCES [dbo].[Battles] (
[name]
)
GO