-
Notifications
You must be signed in to change notification settings - Fork 18
Database structure
Fulvio edited this page Feb 3, 2023
·
4 revisions
This image is an high level representation of a database for storing chess games:
The meaning of most fields should be obvious with an example. Let's take this game encode as a PGN:
[Event "Olympic games"]
[Site "Munchen"]
[Date "1958"]
[White "Walther"]
[Black "Tal,M"]
[Result "0-1"]
[Source "Exeter Chess Club"]
[Annotator "DrDave"]
1. e4 c5 2. Ne2 Nf6 3. d3 Nc6 4. Nd2
{Natural moves in the opening}
4... d5 5. c3 dxe4 6. dxe4 g6 7. Qc2 Bg7 8. a4 $2 O-O 9. Nc4 $2 Na5 10. Nf4
{ Tal gives White's formation a sharp push, and after some wobbling, it collapses.}
10... e5 $1 11. Nd5 Nxe4 12. Qxe4 Nb3 13. Ra3 Bf5 14. Qe3 Nxc1 15. Qxc5 Re8
16. Qe3 Bf8 17. Nb4 a5 18. Nxa5 Qxa5 19. Qxc1 Bxb4 20. cxb4 Qxb4+ 21. Rc3 Qe4+
22. Be2 Rxa4 23. f3 Qb4 24. g4 e4 $1 25. f4 Ra2 $1 26. gxf5 Rxb2 27. O-O $1
{ At last! But Black's nicely centralised and active forces are still in control. }
27... Rxe2 28. Rc8 Qb6+ 29. Kh1 Rxc8 30. Qxc8+ Kg7 31. fxg6 hxg6 32. f5 Qf6 33. Qxb7 Qe5
0-1
The text "Olympic games" is stored into the table Event and assigned the ID 0
The text "Munchen" is stored into the table Site and assigned the ID 0
The text "Walther" is stored into the table Player and assigned the ID 0
The empty text "" is stored into the table Round and assigned the ID 0
The text "Tal,M" is stored into the table Player and assigned the ID 1
The record inserted in the table Game would be:
GameID: 0
EventID: 0
SiteID: 0
RoundID: 0
WhiteID: 0
BlackID: 1
Date: 1958
Result: 0-1
PlyCount: 66
VariationCount: 0
CommentCount: 3
NagCount: 6
Two record inserted in the table TagPair:
TagPairID: 0
GameID: 0
Tag: Source
Value: Exeter Chess Club
TagPairID: 1
GameID: 0
Tag: Annotator
Value: DrDave
three records into the table Comment:
CommentID: 0
GameID: 0
Comment: Natural moves in the opening
CommentID: 1
GameID: 0
Comment: Tal gives White's formation a sharp push, and after some wobbling, it collapses.
CommentID: 2
GameID: 0
Comment: At last! But Black's nicely centralised and active forces are still in control.
and finally one record into the table PositionSearch
GameID: 0
Moves:
1. e4 c5 2. Ne2 Nf6 3. d3 Nc6 4. Nd2 {}
4... d5 5. c3 dxe4 6. dxe4 g6 7. Qc2 Bg7 8. a4 $2 O-O 9. Nc4 $2 Na5 10. Nf4 {}
10... e5 $1 11. Nd5 Nxe4 12. Qxe4 Nb3 13. Ra3 Bf5 14. Qe3 Nxc1 15. Qxc5 Re8
16. Qe3 Bf8 17. Nb4 a5 18. Nxa5 Qxa5 19. Qxc1 Bxb4 20. cxb4 Qxb4+ 21. Rc3 Qe4+
22. Be2 Rxa4 23. f3 Qb4 24. g4 e4 $1 25. f4 Ra2 $1 26. gxf5 Rxb2 27. O-O $1 {}
27... Rxe2 28. Rc8 Qb6+ 29. Kh1 Rxc8 30. Qxc8+ Kg7 31. fxg6 hxg6 32. f5 Qf6 33. Qxb7 Qe5