Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Team5 Sports League application
Manage
Activity
Members
Labels
Plan
Issues
37
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Haoyu Sun
Team5 Sports League application
Commits
ef1ec53e
Commit
ef1ec53e
authored
2 months ago
by
Haoyu Sun
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
50aee33a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/resources/sports.sql
+98
-0
98 additions, 0 deletions
src/main/resources/sports.sql
with
98 additions
and
0 deletions
src/main/resources/sports.sql
0 → 100644
+
98
−
0
View file @
ef1ec53e
CREATE
DATABASE
IF
NOT
EXISTS
sports
;
USE
sports
;
drop
table
if
exists
match_item
;
drop
table
if
exists
ranking
;
drop
table
if
exists
information
;
drop
table
if
exists
images
;
CREATE
TABLE
information
(
id
INT
AUTO_INCREMENT
PRIMARY
KEY
,
username
VARCHAR
(
50
)
UNIQUE
NOT
NULL
,
email
VARCHAR
(
50
)
UNIQUE
NOT
NULL
,
password
VARCHAR
(
255
)
NOT
NULL
,
role
VARCHAR
(
20
)
DEFAULT
'USER'
NOT
NULL
);
create
table
if
not
exists
match_item
(
-- Match ID
id
BIGINT
AUTO_INCREMENT
PRIMARY
KEY
,
-- Sport type
sport
ENUM
(
'Pools'
,
'Darts'
,
'TableTennis'
)
NOT
NULL
,
-- Player A ID
player_AId
INT
NULL
,
-- Player B ID
player_BId
INT
NULL
,
plan_Time
DATETIME
NOT
NULL
,
-- Match status
status
ENUM
(
'pending'
,
'confirmed'
,
'completed'
)
DEFAULT
'pending'
,
score_a
INT
DEFAULT
0
,
score_b
INT
DEFAULT
0
,
confirm_a
BOOLEAN
DEFAULT
FALSE
,
confirm_b
BOOLEAN
DEFAULT
FALSE
,
winner_id
BIGINT
DEFAULT
NULL
#
FOREIGN
KEY
(
player_AId
)
REFERENCES
information
(
id
)
ON
DELETE
CASCADE
,
#
FOREIGN
KEY
(
player_BId
)
REFERENCES
information
(
id
)
ON
DELETE
CASCADE
#
FOREIGN
KEY
(
player_AId
)
REFERENCES
information
(
id
)
ON
DELETE
SET
NULL
,
#
FOREIGN
KEY
(
player_BId
)
REFERENCES
information
(
id
)
ON
DELETE
SET
NULL
);
CREATE
TABLE
IF
NOT
EXISTS
ranking
(
id
INT
AUTO_INCREMENT
PRIMARY
KEY
,
user_id
INT
NOT
NULL
,
sport
ENUM
(
'Pools'
,
'Darts'
,
'TableTennis'
)
NOT
NULL
,
wins
INT
DEFAULT
0
,
username
VARCHAR
(
255
)
DEFAULT
NULL
,
UNIQUE
(
user_id
,
sport
)
-- 添加唯一约束
);
CREATE
TABLE
images
(
id
INT
AUTO_INCREMENT
PRIMARY
KEY
,
url
VARCHAR
(
255
)
NOT
NULL
,
-- 图片文件名或路径
uploaded_at
TIMESTAMP
DEFAULT
CURRENT_TIMESTAMP
-- 上传时间
);
delete
from
information
;
delete
from
match_item
;
delete
from
ranking
;
INSERT
INTO
information
(
id
,
username
,
email
,
password
,
role
)
VALUES
(
1
,
'shy'
,
'shy@creditsafe.com'
,
'$2a$16$R0aSGzbklUhpRfIMhocewephgUDMFOffLb7faSwwHusqHh81G026i'
,
'USER'
);
INSERT
INTO
information
(
id
,
username
,
email
,
password
,
role
)
VALUES
(
2
,
'zyb'
,
'zyb@creditsafe.com'
,
'$2a$16$R0aSGzbklUhpRfIMhocewephgUDMFOffLb7faSwwHusqHh81G026i'
,
'USER'
);
INSERT
INTO
information
(
id
,
username
,
email
,
password
,
role
)
VALUES
(
3
,
'xzc'
,
'xzc@creditsafe.com'
,
'$2a$16$R0aSGzbklUhpRfIMhocewephgUDMFOffLb7faSwwHusqHh81G026i'
,
'USER'
);
INSERT
INTO
information
(
id
,
username
,
email
,
password
,
role
)
VALUES
(
4
,
'xx'
,
'xx@creditsafe.com'
,
'$2a$16$R0aSGzbklUhpRfIMhocewephgUDMFOffLb7faSwwHusqHh81G026i'
,
'USER'
);
insert
into
match_item
(
sport
,
player_AId
,
player_BId
,
plan_Time
,
status
,
score_a
,
score_b
,
confirm_a
,
confirm_b
,
winner_id
)
values
-- test data
-- 1: Pending status
(
'Pools'
,
1
,
2
,
'2024-11-25 14:30:00'
,
'pending'
,
0
,
0
,
FALSE
,
FALSE
,
NULL
),
-- 2: Confirmed status, Player 3 wins
(
'Darts'
,
3
,
4
,
'2024-11-26 16:00:00'
,
'confirmed'
,
3
,
2
,
TRUE
,
TRUE
,
3
),
-- 3: Completed status, Player 6 wins
(
'TableTennis'
,
1
,
2
,
'2024-11-27 18:00:00'
,
'completed'
,
21
,
18
,
TRUE
,
TRUE
,
2
),
-- 4: Pending status
(
'Pools'
,
2
,
1
,
'2024-11-28 20:00:00'
,
'pending'
,
0
,
0
,
FALSE
,
FALSE
,
NULL
),
-- 5: Completed status, Player 9 wins
(
'Darts'
,
1
,
2
,
'2024-11-29 15:30:00'
,
'completed'
,
300
,
280
,
TRUE
,
TRUE
,
2
),
-- 6: Confirmed status, Player 1 wins
(
'TableTennis'
,
1
,
2
,
'2024-11-30 17:00:00'
,
'confirmed'
,
3
,
1
,
TRUE
,
TRUE
,
1
),
(
'TableTennis'
,
null
,
null
,
'2024-12-20 17:00:00'
,
'pending'
,
0
,
0
,
false
,
false
,
null
),
(
'TableTennis'
,
null
,
null
,
'2024-12-21 17:00:00'
,
'pending'
,
0
,
0
,
false
,
false
,
null
),
(
'Pools'
,
null
,
null
,
'2024-12-22 17:00:00'
,
'pending'
,
0
,
0
,
false
,
false
,
null
),
(
'Pools'
,
null
,
null
,
'2024-12-23 17:00:00'
,
'pending'
,
0
,
0
,
false
,
false
,
null
),
(
'Pools'
,
null
,
null
,
'2024-12-24 17:00:00'
,
'pending'
,
0
,
0
,
false
,
false
,
null
),
(
'Darts'
,
null
,
null
,
'2024-12-25 17:00:00'
,
'pending'
,
0
,
0
,
false
,
false
,
null
),
(
'Darts'
,
null
,
null
,
'2024-12-26 17:00:00'
,
'pending'
,
0
,
0
,
false
,
false
,
null
),
(
'Darts'
,
null
,
null
,
'2024-12-27 17:00:00'
,
'pending'
,
0
,
0
,
false
,
false
,
null
);
INSERT
INTO
ranking
(
user_id
,
username
,
sport
,
wins
)
VALUES
(
1
,
'shy'
,
'Pools'
,
0
),
(
1
,
'shy'
,
'Darts'
,
0
),
(
1
,
'shy'
,
'TableTennis'
,
0
),
(
2
,
'zyb'
,
'Pools'
,
0
),
(
2
,
'zyb'
,
'Darts'
,
0
),
(
2
,
'zyb'
,
'TableTennis'
,
0
),
(
3
,
'xzc'
,
'Pools'
,
0
),
(
3
,
'xzc'
,
'Darts'
,
0
),
(
3
,
'xzc'
,
'TableTennis'
,
0
),
(
4
,
'xx'
,
'Pools'
,
0
),
(
4
,
'xx'
,
'Darts'
,
0
),
(
4
,
'xx'
,
'TableTennis'
,
0
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment