-
Notifications
You must be signed in to change notification settings - Fork 0
/
DB.sql
executable file
·83 lines (83 loc) · 2.75 KB
/
DB.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
USE [TheThreeDB]
GO
/****** Object: Table [dbo].[Baseroute] Script Date: 2019/6/4 16:25:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Baseroute](
[baseNumber] [int] NOT NULL,
[startAddr] [varchar](100) NOT NULL,
[destAddr] [varchar](100) NOT NULL,
CONSTRAINT [PK_Baseroute] PRIMARY KEY CLUSTERED
(
[baseNumber] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Car] Script Date: 2019/6/4 16:25:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Car](
[carNumber] [varchar](50) NOT NULL,
[people1Number] [int] NULL,
[people2Number] [int] NULL,
[routeNumber] [int] NULL,
CONSTRAINT [PK_Car] PRIMARY KEY CLUSTERED
(
[carNumber] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Driver] Script Date: 2019/6/4 16:25:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Driver](
[peopleNumber] [int] NOT NULL,
[driverNumber] [varchar](50) NOT NULL,
[peopleName] [varchar](10) NOT NULL,
[peopleAge] [int] NOT NULL,
[driverAge] [int] NOT NULL,
[phoNumber] [varchar](50) NOT NULL,
[peopleState] [int] NOT NULL,
CONSTRAINT [PK_Driver] PRIMARY KEY CLUSTERED
(
[peopleNumber] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Route] Script Date: 2019/6/4 16:25:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Route](
[routeNumber] [int] NOT NULL,
[startAddr] [varchar](100) NOT NULL,
[destAddr] [varchar](100) NOT NULL,
[mAddr] [varchar](200) NULL,
CONSTRAINT [PK_Route] PRIMARY KEY CLUSTERED
(
[routeNumber] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Car] WITH CHECK ADD CONSTRAINT [FK_Car_Driver] FOREIGN KEY([people1Number])
REFERENCES [dbo].[Driver] ([peopleNumber])
GO
ALTER TABLE [dbo].[Car] CHECK CONSTRAINT [FK_Car_Driver]
GO
ALTER TABLE [dbo].[Car] WITH CHECK ADD CONSTRAINT [FK_Car_Driver1] FOREIGN KEY([people2Number])
REFERENCES [dbo].[Driver] ([peopleNumber])
GO
ALTER TABLE [dbo].[Car] CHECK CONSTRAINT [FK_Car_Driver1]
GO
ALTER TABLE [dbo].[Car] WITH CHECK ADD CONSTRAINT [FK_Car_Route] FOREIGN KEY([routeNumber])
REFERENCES [dbo].[Route] ([routeNumber])
GO
ALTER TABLE [dbo].[Car] CHECK CONSTRAINT [FK_Car_Route]
GO