schema.sql 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. DROP TABLE IF EXISTS Cts_times;
  2. CREATE TABLE Cts_times(
  3. mapid TEXT,
  4. gametype TEXT,
  5. trank INT,
  6. tvalue INT,
  7. PRIMARY KEY (mapid, gametype, trank),
  8. FOREIGN KEY (mapid, gametype, trank) REFERENCES Cts_ranks(mapid, gametype, idrank)
  9. );
  10. DROP TABLE IF EXISTS Cts_ranks;
  11. CREATE TABLE Cts_ranks(
  12. mapid TEXT,
  13. gametype TEXT,
  14. idrank INT,
  15. idvalue TEXT,
  16. PRIMARY KEY (mapid, gametype, idrank)
  17. );
  18. DROP TABLE IF EXISTS Id2alias;
  19. CREATE TABLE Id2alias(
  20. rtype TEXT,
  21. cryptokey TEXT,
  22. alias TEXT,
  23. PRIMARY KEY (cryptokey)
  24. );
  25. drop table if exists Speed;
  26. create table Speed(
  27. mapid text,
  28. speed float,
  29. primary key (mapid)
  30. );
  31. drop table if exists Fastest_players;
  32. create table Fastest_players (
  33. mapid text,
  34. idvalue text,
  35. primary key (mapid)
  36. );
  37. -- These table fields are unaltered.
  38. -- Exerpts from source/qcsrc/race.qc
  39. -- // player improved his existing record, only have to iterate on ranks between new and old recs
  40. -- for (i = prevpos; i > newpos; --i)
  41. -- {
  42. -- db_put(ServerProgsDB, strcat(map, rr, "time", ftos(i)), ftos(race_readTime(map, i - 1)));
  43. -- db_put(ServerProgsDB, strcat(map, rr, "crypto_idfp", ftos(i)), race_readUID(map, i - 1));
  44. -- }
  45. -- ....
  46. -- // store new time itself
  47. -- db_put(ServerProgsDB, strcat(map, rr, "time", ftos(i)), ftos(race_readTime(map, i - 1)));
  48. -- db_put(ServerProgsDB, strcat(map, rr, "crypto_idfp", ftos(i)), race_readUID(map, i - 1));
  49. -- re: foreign key from & to Cts_ranks & Id2alias.
  50. -- An ranked unregistered player will have a row in Cts_ranks, but will not have a row in Id2alias.
  51. -- A registered player may have a row in Id2alias, but may not necessary have a rank.