We need to build a database for a race track about horse rac
We need to build a database for a race track about horse races: Races have a Name and Length Horses are described by Horse Name, Age, and Owner Name Jockeys are described by Jockey Name and Age A jockey is affiliated with a particular club. For clubs we need to store their Names and Addresses. A club has one or more jockeys. The same race can take place multiple times. Jockeys and horses can participate in different races; a jockey can ride different horses and a horse can be handled by different jockeys. For each race we need to record the date of the race, participating jockeys and horses they ride, and also jockeys\' results.
Solution
CREATE TABLE Horses
(
name varchar(256),
age int NOT NULL,
hourse_ID int
PRIMARY KEY (name),
owner_name varchar(255)
)
CREATE TABLE Race
(
name varchar(256),
length int NOT NULL,
PRIMARY KEY(name)
FOREIGN KEY (name) REFERENCES Horses(P_Id)
FOREIGN KEY (P_Id) REFERENCES jockey(P_Id)
)
CREATE TABLE Jockey
(
name varchar(256),
age int NOT NULL,
PRIMARY KEY (p_id)
)
CREATE TABLE Club
(
name varchar(256),
address int NOT NULL,
FOREIGN KEY (P_Id) REFERENCES jockey(P_Id)
)
