1.ERD SQL CODE CREATE TABLE IF NOT EXISTS`client`( clientNumber int(11) NOTNULL, lastName varchar(50) NOTNULL, firstName varchar(50)NOTNULL, address varchar(50) NOTNULL, city varchar(50) NOT NULL, state varchar(50) NOTNULL, postalCode int(11) NOTNULL, tel varchar(25) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=3DEFAULTCHARSET=latin1; CREATE TABLE IF NOT EXISTSguide( guideNumber int(11) NOTNULL, lastName varchar(50) NOTNULL, firstName varchar(50)NOTNULL, address varchar(50) NOTNULL, city varchar(50) NOT NULL, state varchar(50) NOTNULL, postalCode int(11) NOTNULL, tel varchar(25) NOT NULL, dateHired date NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=3DEFAULTCHARSET=latin1; CREATE TABLE IF NOT EXISTStrip( tripID int(11) NOT NULL, `name` varchar(50) NOTNULL, startingLocation varchar(50)NOTNULL, startingState varchar(50)NOTNULL, tripDistance int(11) NOTNULL, MaxGroupSize int(11) NOTNULL, `type` varchar(25) NOTNULL, season varchar(25) NOTNULL ) ENGINE=InnoDB AUTO_INCREMENT=3DEFAULTCHARSET=latin1; CREATE TABLE IF NOT EXISTStrip_clients( tripID int(11) NOT NULL, clientNumber int(11) NOTNULL ) ENGINE=InnoDB DEFAULTCHARSET=latin1; CREATE TABLE IF NOT EXISTStrip_guides( tripID int(11) NOT NULL, guideNumber int(11) NOTNULL ) ENGINE=InnoDB DEFAULTCHARSET=latin1; ALTER TABLE client ADD PRIMARY KEY (clientNumber); ALTER TABLE guide ADD PRIMARY KEY (guideNumber); ALTER TABLE trip ADD PRIMARY KEY (tripID); ALTER TABLE trip_clients ADD PRIMARY KEY (tripID,clientNumber),ADDKEYclientNumber (clientNumber); ALTER TABLE trip_guides ADD PRIMARY KEY (tripID,guideNumber),ADDKEYguideNumber (guideNumber); ALTER TABLE client MODIFY clientNumber int(11)NOTNULL AUTO_INCREMENT,AUTO_INCREMENT=3; ALTER TABLE guide MODIFY guideNumber int(11)NOTNULL AUTO_INCREMENT,AUTO_INCREMENT=3;
ALTER TABLE trip MODIFY tripID int(11) NOTNULLAUTO_INCREMENT,AUTO_INCREMENT=3; ALTER TABLE trip_clients ADD CONSTRAINT trip_clients_ibfk_1FOREIGNKEY(tripID) REFERENCES colonial.trip(tripID)ONDELETECASCADEONUPDATE CASCADE, ADD CONSTRAINT trip_clients_ibfk_2FOREIGNKEY(clientNumber) REFERENCES colonial.client(clientNumber)ONDELETECASCADEON UPDATE CASCADE; ALTER TABLE trip_guides ADD CONSTRAINT trip_guides_ibfk_1FOREIGNKEY(tripID)REFERENCES colonial.trip (tripID) ONDELETECASCADEONUPDATECASCADE, ADD CONSTRAINT trip_guides_ibfk_2FOREIGNKEY(guideNumber) REFERENCES colonial.guide(guideNumber)ONDELETECASCADEON UPDATE CASCADE; Tables created in clude Table Guide Table Client
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
2. Expanding the database to accept classes; Adding date of birth column in table client altertableclientaddcolumndobdatenull; Addition of a table class createtableclass(classNumberintegerprimarykeyauto_increment,descriptionv archar(500)notnull,maxPersonsintegernotnull,feesdecimalnotnull); Addition of enrollment table createtableenrollment(classNumberintegernotnull,clientNumberintegernotnu ll,primarykey(classNumber,clientNumber),foreignkey(classNumber)references class(classNumber)onupdatecascadeondeletecascade,foreignkey(clientNumber) referencesclient(clientNumber)onupdatecascadeondeletecascade);
New Schema Complete SQL code CREATE TABLE IF NOTEXISTSclass( classNumber int(11)NOTNULL, description varchar(500)NOTNULL, maxPersons int(11)NOTNULL, fees decimal(10,0)NOTNULL ) ENGINE=InnoDB DEFAULTCHARSET=latin1; CREATE TABLE IF NOTEXISTS`client`( clientNumber int(11)NOTNULL, lastName varchar(50)NOTNULL, firstName varchar(50)NOTNULL, address varchar(50)NOTNULL, city varchar(50)NOTNULL, state varchar(50)NOTNULL, postalCode int(11)NOTNULL, tel varchar(25)NOTNULL, dob date DEFAULTNULL ) ENGINE=InnoDB AUTO_INCREMENT=3DEFAULTCHARSET=latin1;
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
CREATE TABLE IF NOTEXISTSenrollment( classNumber int(11)NOTNULL, clientNumber int(11)NOTNULL ) ENGINE=InnoDB DEFAULTCHARSET=latin1; CREATE TABLE IF NOTEXISTSguide( guideNumber int(11)NOTNULL, lastName varchar(50)NOTNULL, firstName varchar(50)NOTNULL, address varchar(50)NOTNULL, city varchar(50)NOTNULL, state varchar(50)NOTNULL, postalCode int(11)NOTNULL, tel varchar(25)NOTNULL, dateHired date NOTNULL ) ENGINE=InnoDB AUTO_INCREMENT=3DEFAULTCHARSET=latin1; CREATE TABLE IF NOTEXISTStrip( tripID int(11) NOTNULL, `name` varchar(50)NOTNULL, startingLocationvarchar(50)NOTNULL, startingState varchar(50)NOTNULL, tripDistance int(11)NOTNULL, MaxGroupSize int(11)NOTNULL, `type` varchar(25)NOTNULL, season varchar(25)NOTNULL ) ENGINE=InnoDB AUTO_INCREMENT=3DEFAULTCHARSET=latin1; CREATE TABLE IF NOTEXISTStrip_clients( tripID int(11) NOTNULL, clientNumber int(11)NOTNULL ) ENGINE=InnoDB DEFAULTCHARSET=latin1; CREATE TABLE IF NOTEXISTStrip_guides( tripID int(11) NOTNULL, guideNumber int(11)NOTNULL ) ENGINE=InnoDB DEFAULTCHARSET=latin1; ALTER TABLE class ADD PRIMARY KEY (classNumber); ALTER TABLE client ADD PRIMARY KEY (clientNumber); ALTER TABLE enrollment ADD PRIMARY KEY (classNumber,clientNumber),ADDKEY clientNumber (clientNumber);
ALTER TABLE guide ADD PRIMARY KEY (guideNumber); ALTER TABLE trip ADD PRIMARY KEY (tripID); ALTER TABLE trip_clients ADD PRIMARY KEY (tripID,clientNumber),ADDKEYclientNumber (clientNumber); ALTER TABLE trip_guides ADD PRIMARY KEY (tripID,guideNumber),ADDKEYguideNumber (guideNumber); ALTER TABLE class MODIFY classNumberint(11)NOTNULLAUTO_INCREMENT; ALTER TABLE client MODIFY clientNumberint(11)NOTNULL AUTO_INCREMENT,AUTO_INCREMENT=3; ALTER TABLE guide MODIFY guideNumberint(11)NOTNULL AUTO_INCREMENT,AUTO_INCREMENT=3; ALTER TABLE trip MODIFY tripID int(11)NOTNULL AUTO_INCREMENT,AUTO_INCREMENT=3; ALTER TABLE enrollment ADD CONSTRAINT enrollment_ibfk_1FOREIGNKEY(classNumber) REFERENCES class (classNumber)ONDELETECASCADEONUPDATE CASCADE, ADD CONSTRAINT enrollment_ibfk_2FOREIGNKEY(clientNumber) REFERENCES client(clientNumber)ONDELETECASCADEONUPDATE CASCADE; ALTER TABLE trip_clients ADD CONSTRAINT trip_clients_ibfk_1FOREIGNKEY(tripID) REFERENCES colonial.trip(tripID)ONDELETECASCADEON UPDATE CASCADE, ADD CONSTRAINT trip_clients_ibfk_2FOREIGNKEY (clientNumber) REFERENCEScolonial.client(clientNumber)ON DELETE CASCADE ONUPDATECASCADE; ALTER TABLE trip_guides ADD CONSTRAINT trip_guides_ibfk_1FOREIGNKEY(tripID) REFERENCES colonial.trip(tripID)ONDELETECASCADEON UPDATE CASCADE,
ADD CONSTRAINT trip_guides_ibfk_2FOREIGNKEY(guideNumber) REFERENCES colonial.guide(guideNumber)ONDELETECASCADEON UPDATE CASCADE; 3. Expanding database to include invoice to clients Addition of table invoice createtableinvoice(invoiceNumberintegerprimarykey,clientNumberintegernot null,invoiceDatedatenotnull,totalDuedecimalnotnull,foreignkey(clientNum ber)referencesclient(clientNumber)onupdatecascadeondeletecascade); Addition of invoice_classes to hold classes for an invoice createtableinvoice_classes(invoiceNumberintegernotnull,classNumberinteger notnull,primarykey(invoiceNumber,classNumber),foreignkey(invoiceNumber)re ferencesinvoice(invoiceNumber)onupdatecascadeondeletecascade,foreignkey( classNumber)referencesclass(classNumber)onupdatecascadeondeletecascade); Revised schema
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser