Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. create table Pilot
  2. (
  3. IdPilot int not null Constraint PrimaryPilot Primary Key,
  4. Surname varchar(30) not null,
  5. age int not null,
  6. IdRank int not null constraint ForeignPilotRank Foreign Key
  7. references Rank(IdRank),
  8. IdCompet int not null Constraint ForeignCompetPilot Foreign Key
  9. references Competition(IdCompetition),
  10. IdResults int not null Constraint ForeignResultsPilot foreign key
  11. references Results(IdResults)
  12. )
  13. alter table Pilot
  14. add IdCar int not null Constraint ForeignCarPilot Foreign Key
  15. references Car(IdCar)
  16. create table Rank
  17. (
  18. IdRank int not null constraint PrimaryRank Primary Key,
  19. RankName varchar(4) not null
  20. )
  21.  
  22. create table Results
  23. (
  24. IdResults int not null constraint PrimaryResults Primary Key,
  25. NameResult varchar(5) not null,
  26. IdRank int not null constraint ForeignRank Foreign Key
  27. references Rank(IdRank)
  28. )
  29.  
  30. create table Judge
  31. (
  32. IdJudge int not null constraint PrimaryFudge Primary Key,
  33. Surname varchar(30) not null,
  34. Experience int not null
  35. )
  36.  
  37. create table Type
  38. (
  39. IdType int not null constraint PrimaryType Primary Key,
  40. Name varchar(30) not null,
  41. IdJudge int not null Constraint ForeignJudge Foreign Key
  42. references Judge(IdJudge)
  43. )
  44.  
  45. create table Competition
  46. (
  47. IdCompetition int not null Constraint PrimaryCom Primary Key,
  48. Date DateTime not null,
  49. IdType int not null constraint ForeignComType Foreign Key
  50. references Type(IdType),
  51. IdResult int not null constraint ForeignResultsCom foreign key
  52. references Results(IdResults)
  53. )
  54.  
  55. create table Car
  56. (
  57. IdCar int not null Constraint PrimaryCar primary key,
  58. Make varchar(20),
  59. Power int not null,
  60. IdPilot int not null constraint ForeignPilotCar Foreign Key
  61. references Pilot(IdPilot),
  62. IdRank int not null constraint ForeignRankPilot Foreign Key
  63. references Rank(IdRank)
  64. )
  65. create table Track
  66. (
  67. IdTrack int not null Constraint PrimaryTrack Primary Key,
  68. Name varchar(30) not null,
  69. Length int not null,
  70. IdJudge int not null constraint ForeignTrackJudge Foreign Key
  71. references Judge(IdJudge)
  72. )
  73.  
  74. --1
  75. alter table Competition
  76. add lasting int
  77. --2
  78. alter table Pilot
  79. alter column Surname varchar(25)
  80. --3
  81. Alter table Judge
  82. add constraint UniqueSur Unique (Surname)
  83. --4
  84. alter table Car
  85. add Speed varchar(50)
  86.  
  87. /*alter table car
  88. add Constraint SpeedLen Check (Len(speed=<30))*/
  89. --5
  90. alter table Track
  91. add Constraint TrackOdd check(Length%2>=100 and Length%2<=10000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement