View sourcecode

The following files exists in this folder. Click to view.

Stegen_1c.sql

89 lines ASCII Unix (LF)
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
-- Created by Redgate Data Modeler (https://datamodeler.redgate-platform.com)
-- Last modification date: 2025-12-13 23:27:30.139

-- tables
-- Table: Ladders
CREATE TABLE Ladders (
    ladderId int  NOT NULL AUTO_INCREMENT,
    userId int  NOT NULL,
    laddername varchar(30)  NOT NULL,
    description varchar(1000)  NULL,
    pointsystem varchar(10)  NOT NULL,
    startingpoints int  NOT NULL,
    minbet int  NOT NULL,
    minbetPercent int  NULL,
    minbetTime int  NULL,
    open int  NOT NULL,
    playerroof int  NULL,
    startdate datetime  NOT NULL,
    enddate datetime  NULL,
    createdate timestamp  NOT NULL,
    CONSTRAINT Ladders_pk PRIMARY KEY (ladderId)
);

-- Table: Matches
CREATE TABLE Matches (
    matchId int  NOT NULL AUTO_INCREMENT,
    challengerId int  NOT NULL,
    defenderId int  NOT NULL,
    winnerId int  NULL,
    challengerpoints int  NOT NULL,
    defenderpoints int  NOT NULL,
    createdate timestamp  NOT NULL,
    responsedate datetime  NULL,
    matchdate datetime  NULL,
    status varchar(10)  NOT NULL,
    CONSTRAINT Matches_pk PRIMARY KEY (matchId)
);

-- Table: Players
CREATE TABLE Players (
    playerId int  NOT NULL AUTO_INCREMENT,
    userId int  NOT NULL,
    ladderId int  NOT NULL,
    createdate timestamp  NOT NULL,
    active int  NOT NULL DEFAULT 1,
    CONSTRAINT Players_pk PRIMARY KEY (playerId)
);

-- Table: Users
CREATE TABLE Users (
    userId int  NOT NULL AUTO_INCREMENT,
    userlvl varchar(10)  NOT NULL,
    password varchar(80)  NOT NULL,
    username varchar(50)  NOT NULL,
    incorrectLoginAttempts int  NOT NULL DEFAULT 0,
    latestLogin datetime  NOT NULL,
    active int  NOT NULL DEFAULT 1,
    createdate timestamp  NOT NULL,
    CONSTRAINT Users_pk PRIMARY KEY (userId)
);

-- foreign keys
-- Reference: Ladders_Users (table: Ladders)
ALTER TABLE Ladders ADD CONSTRAINT Ladders_Users FOREIGN KEY Ladders_Users (userId)
    REFERENCES Users (userId);

-- Reference: Matches_challengers (table: Matches)
ALTER TABLE Matches ADD CONSTRAINT Matches_challengers FOREIGN KEY Matches_challengers (challengerId)
    REFERENCES Players (playerId);

-- Reference: Matches_defenders (table: Matches)
ALTER TABLE Matches ADD CONSTRAINT Matches_defenders FOREIGN KEY Matches_defenders (defenderId)
    REFERENCES Players (playerId);

-- Reference: Matches_winners (table: Matches)
ALTER TABLE Matches ADD CONSTRAINT Matches_winners FOREIGN KEY Matches_winners (winnerId)
    REFERENCES Players (playerId);

-- Reference: Players_Ladders (table: Players)
ALTER TABLE Players ADD CONSTRAINT Players_Ladders FOREIGN KEY Players_Ladders (ladderId)
    REFERENCES Ladders (ladderId);

-- Reference: Players_Users (table: Players)
ALTER TABLE Players ADD CONSTRAINT Players_Users FOREIGN KEY Players_Users (userId)
    REFERENCES Users (userId);

-- End of file.