MGHH_DDL-2
MGHH_DDL-2
-- You only need to run these DROP commands if you want to drop the tables and
start over from a blank database!
-- For example, if you created the tables as described in class with the small
number of horses and now you need to create the full dataset
-- OR if you are working on the project and think you have done something to mess
up the database, DROP and recreate the tables to get a fresh start/
-- If you run the drop command for a table that does not exist you will get an
error message - no big deal, just move on
--
***********************************************************************************
**********************************
--
-- The first time you run this code you either:
-- 1. Just need to drop horses, customers, medications, and orders (if you have
been following along)
-- 2. You don't need to drop anything if you have not preivously created any tables
--
--
***********************************************************************************
**********
--Then barns, which also do not reference anything, but we must have barns to have
stables
--and we must have stables (and customers) to have horses. Remember, it matters
what order you create the tables when things reference one another!
--Races do not reference anything, but they must exist in order for horses to
participate in races
CREATE TABLE races (
RaceID varchar(5) CONSTRAINT pk_races PRIMARY KEY,
RaceName varchar(100),
TrackName varchar(100),
Location varchar(100)
);
--Workers (also called employees, but I have some similarly names tables in the
database for other examples during class)
--only refer to themselves in this unary relationship