STEP 1: WRITE A SCRIPT TO CREATE the RAG (Relational Auto Group) Database and Tables (plus all PK and FK constraints) us

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

STEP 1: WRITE A SCRIPT TO CREATE the RAG (Relational Auto Group) Database and Tables (plus all PK and FK constraints) us

Post by answerhappygod »

STEP 1: WRITE A SCRIPT TO CREATE the RAG (Relational Auto Group)Database and Tables (plus all PK and FK constraints) using this ERDThis creation script is very similar to what you did in the Try itOut. Be careful of the AUTO_INCREMENT in some tables (as it may notalways be the default (1,1).
STEP 2 After creating your tables, append your script by copyingand pasting the red text below to insert data into your tables.
Insert INTO dealership Values (7111,'RAG Clearfield','123 MainStreet','Clearfield','UT',84104), (5626,'Relational GroupOgden','123 Jackson Ave','Ogden','UT',84108), (7845,'RAGLayton','123 Pioneer Dr','Layton','UT',84101),(1236,'Holliday','123 Christmas Cir','Holladay','UT',84117),(8988,'RAG SugarHouse','123 Easy Way','Salt Lake City','UT',84106);INSERT INTO position (positionName) VALUES ('Sales'), ('Mechanic'),('Office'); INSERT INTO Service (ServiceName, ServiceRate) VALUES('Oil Change',29.95), ('Tire Rotation',15.95), ('SafetyInspection',12), ('Emissions Testing',28), ('Labor - General',89),('Disposal Fees',4.95), ('Cash Wash',7.5), ('Vacuum',2.5); INSERTINTO Employee (EmpFirst, EmpLast, EmpAddress, EmpCity, EmpState,EmpZip, EmpPhone, EmpDOB) VALUES ('Rodriguez','Herminio','135Pacocha Square','RockSprings','WY','82901','3079796360','1969-07-07'),('Schimmel','Melba','2781 CasperVillages','Ogden','UT','84408','8016356458','1964- 10-10'),('Oberbrunner','Tyrell','3553 Elise Meadow','Salt LakeCity','UT','84117','8015452187','1994-07-31'),('Dickinson','Alvah','4247FramiSprings','Evanston','WY','82930','3074587412','1977-02-21'),('Hane','Olaf','6991 Laurence Wall','Salt LakeCity','UT','84106','8012578964','1990-10-18'),('Muller','Sharon','3721 Halie Gateway','ParkCity','UT','84101','3853339978','1982-01-15'), ('Murray','Jadyn','6569 KhalilExpressway','Layton','UT','84404','3857891234','2000-05-02'),('Ebert','Aiyana','400 CeceliaMountains','Clearfield','UT','84405','8015456318','1966-06-06'),('Schaden','Kattie','203 SchneiderPlains','Ogden','UT','84408','8016356874','1998-08-07'),('Langosh','Kenneth','245 Ebert Prairie','ParkCity','UT','84101','3857554422','1998-11-08'); INSERT INTO customer(CustFirst, CustLast) VALUES ('Schuster','Ryann'),('Mayer','Jane'), ('Marvin','Richard'), ('Crist','Lafayette'),('Johns','Maggie'), ('Flatley','Austen'), ('Yost','Maurice'),('Graham','Fiona'), ('Wisozk','Mariano'), ('Russel','Sherwood'),('Fisher','Madyson'), ('Grady','Cecilia'), ('Kautzer','Sister'),('Kilback','Brennan'), ('Bednar','Brenda'), ('Kovacek','Amari'),('Marquardt','Juwan'), ('Rogahn','Travon'), ('Hudson','Yadira'),('Gislason','Jeramie'), ('Grimes','Kattie'), ('Pollich','Lela'),('Howell','Brianne'), ('Nader','Patricia'), ('Wisoky','Anderson'),('Marks','Ryley'), ('Hane','Lola'), ('Jast','Monique'),('Heller','Elisabeth'), ('Aufderhar','Archibald'),('Murray','Antonio'), ('Abshire','Kade'), ('Ebert','Clark'),('Hirthe','Lora'), ('Tromp','Gianni'), ('Mayer','Makenzie'),('Dach','Natalie'), ('Kiehn','Kadin'), ('Wolf','Chaz'),('Bogan','Sadye'), ('Olson','Ciara'), ('Leffler','Florencio'),('Cassin','Demond'), ('Rohan','Hallie'), ('Gottlieb','Leilani'),('Bruen','Lydia'), ('Corwin','Veda'), ('Tromp','Shana'),('Carroll','Ernestina'), ('Koepp','Yadira'), ('Powlowski','Doris'),('Cummerata','Grace'), ('Halvorson','Meda'), ('Heller','Jarret'),('Sauer','Telly'), ('Batz','Felipe'), ('Towne','Harvey'),('Batz','Ansley'), ('Brekke','Emmitt'), ('Koch','Dorthy'),('Daniel','Piper'), ('Schiller','Carol'), ('Parisian','Milo'),('Halvorson','Lambert'), ('Reichel','Delmer'), ('Ziemann','Omari'),('Powlowski','Mario'), ('OKeefe','Kamille'), ('OKeefe','Felicity'),('Mohr','Hadley'), ('Fadel','Doyle'), ('DuBuque','Cesar'),('Hagenes','Dillan'), ('OConner','Walker'), ('Hayes','Armani'),('Hilpert','Elsa'), ('Gleichner','Novella'),('Stiedemann','Allene'), ('Bernhard','Eldon'), ('Harris','Willie'),('Larson','Tom'), ('Trantow','Seth'), ('Torphy','Leland'),('Bashirian','Kris'), ('Beier','Joe'), ('Mertz','Daphney'),('Wintheiser','Erika'), ('Luettgen','Carmine'),('Friesen','Kenyatta'), ('Lueilwitz','Laverne'),('Durgan','Eldon'), ('Kilback','Preston'), ('Bernhard','Sophia'),('Kuhic','Verna'), ('Bauch','Carmel'), ('Hintz','Presley'),('Lindgren','Rosie'), ('Hegmann','Johathan'), ('Kreiger','Sammy'),('Hermiston','Sigmund'), ('Murazik','Weston'),('Predovic','Juston'), ('Hermann','Malika'),('Jaskolski','Kendra'), ('Kunde','Rosamond'), ('Becker','Anibal'),('Hane','Reta'), ('Crona','Kyla'), ('McClure','Chaya'),('Goldner','Myriam'), ('Bergstrom','Abdul'), ('Veum','Cleve'),('Collins','Christopher'), ('Murray','Milford'),('Hudson','Jevon'), ('Wyman','Emory'), ('Bauch','Dorothea'),('Dibbert','Judson'), ('Conroy','Sean'), ('Gerlach','Coby'),('Stark','Dustin'), ('Guann','Pearl'), ('Shanahan','Davon'),('Fritsch','Shayna'), ('Sauer','Gail'), ('Nitzsche','Mariam'),('Harvey','Krystel'), ('Casper','Annabell'),('VonRueden','Katherine'), ('Spencer','Sienna'),('Erdman','Dolores'), ('Veum','Jan'), ('Braun','Matteo'),('Jewess','Raven'), ('Tremblay','Helga'), ('Lemke','Tess'),('Corwin','Haylie'), ('Towne','Santino'), ('Williamson','Orpha'),('Lindgren','Rebekah'), ('Kozey','Clarissa'), ('Hilll','Domingo'),('Rolfson','Juston'), ('Schmitt','Amya'), ('Lehner','Stanley'),('Bergstrom','Justina'), ('Schiller','Cathrine'),('Kuhlman','Green'), ('Wolff','Kade'), ('Roberts','Pablo'),('Buckridge','Arianna'), ('Aufderhar','Cynthia'),('Monahan','Deontae'), ('Rice','Javonte'), ('Cormier','Colton'),('Kuhn','Alyce'), ('DAmore','Lisa'), ('Rempel','Celestino'),('Russel','Addie'), ('Gleichner','Kevon'), ('Ryan','Jean'),('OConnell','Trever'), ('Gleichner','Karen'),('Marquardt','Irving'), ('Schulist','Bridgette'),('Bernier','Vivianne'), ('Kertzmann','Buford'),('Abshire','Alessandro'), ('Fahey','Walker'),('Ziemann','Whitney'), ('Abbott','Joy'), ('Sauer','Hilton'),('Shields','Aron'), ('Schaefer','Cyrus'); INSERT INTO Manufacturer(ManufacturerName) VALUES ('BMW'), ('Ford'), ('Toyota'),('Nissan'), ('Dodge'), ('Honda'); INSERT INTO Part (PartName,PartRetail) VALUES ('Oil Filter','11.95'), ('Fuse','1.99'),('Coolant - Quart','3.95'), ('Spark Plug','4'), ('AirFilter','24.95'), ('Carburetor','99.99'), ('AntiFreeze -Gallon','7.77'), ('Tire Valve','0.58'), ('Rain X -Application','4.95'), ('Oil - 10W40','4.95'), ('Oil -Synthetic','7.6'); INSERT INTO Model (ModelName, ManufacturerID)VALUES ('3-Series','1'), ('5-Series','1'), ('F-150','2'),('F-250','2'), ('F-350','2'), ('Camry','3'), ('Camry Hybrid','3'),('Corolla','3'), ('Highlander','3'), ('Accord','6'), ('RAM','5'),('Pathfinder','4'), ('Rogue','4'); INSERT INTO Trim (TrimName,ModelID) VALUES ('318i 4dr Sedan','1'), ('328i 4dr Sedan','1'),('318ti 2dr Hatchback','1'), ('323i 2dr Convertible','1'), ('328i2dr Convertible','1'), ('323is 2dr Coupe','1'), ('328is 2drCoupe','1'), ('M5 4dr Sedan','2'), ('M5 2dr Coupe','2'), ('M5 2drConvertible','2'), ('2dr Extended Cab SB','3'), ('2dr Extended CabLB','3'), ('2dr Extended Cab 4WD LB','3'), ('2dr Extended Cab 4WDSB','3'), ('XLT Lariat 2dr Extended Cab LB','3'), ('XLT Lariat 2drExtended Cab SB','3'), ('XLT Lariat 2dr Extended Cab 4WD LB','3'),('XLT Lariat 2dr Extended Cab 4WD SB','3'), ('XL 2dr Extended CabLB','4'), ('XL 2dr Extended Cab SB','4'), ('XL 2dr Extended Cab 4WDLB','4'), ('XL 2dr Extended Cab 4WD SB','4'), ('2dr Regular CabSB','5'), ('2dr Regular Cab LB','5'), ('2dr Regular Cab 4WDLB','5'), ('2dr Regular Cab 4WD SB','5'), ('LE V6 2dr Coupe','6'),('DX 2dr Coupe','6'), ('LE 2dr Coupe','6'), ('4dr Sedan ','7'),('LE Hybrid','7'), ('LE 4dr Sedan ','7'), ('DX 4dr Wagon','8'),('LE V6 4dr Sedan','8'), ('LX 4dr','10'), ('Laramie Edition','11'),('2dr Short Bed','11'), ('Eddie Bauer Edition','9'), ('Eddie BauerEdition','12'), ('LX V6 4dr','13'); INSERT INTO Vehicle (VehVIN,VehYear, VehColor, VehMileage, TrimID) VALUES('1D4RD4GG9BC660306','18','Red','1234','2'),('3GCCA05V89S596155','18','White','5678','4'),('2CNBE1869T6300748','18','Blue','15456','8'),('2FZACFDK36AW46451','18','Celestial Silver','25212','11'),('2HGFF384744W44RF3','18','White',NULL,'14'),('87JHF5RE3NBV678AA','19','Gray Metallic',NULL,'17'),('4LKJ44829NB442DF3','19','Silver Metallic',NULL,'20'),('5HHHF332AS3000FGB','19','Tan',NULL,'23'),('6JDHGJ88KIGHJFDJC','19','Forrest Green',NULL,'26'),('3JGFKDJDLS855NFCK','20','Blue',NULL,'27'),('6YYDFJS739002NFH2','20','Red',NULL,'28'),('6FHFK3748MJVND029','20','Black',NULL,'29'),('11FJJFJSMHHFHF383','20','Brown',NULL,'30'),('7FNFNW6223KFJHGHG','20','Blue Aqua',NULL,'31'),('6NFJFJFWWNCFNEFH2','21','Pearl White',NULL,'32'),('3638NNFNFLSS33041','21','Sandy Beach',NULL,'33'),('13749NFHDL3733YYR','21','Sandy Beach',NULL,'34'),('144FJFHFMZXZCCVMJ','22','Pearl White',NULL,'33'),('5GHGJFKFQWWEEW32R','22','Barcelona Red',NULL,'34'),('2WSSDFSOSJFGK393U','22','Blue Streak',NULL,'35'),('3ERTY4839FNNBBVEF','22','Blue Streak',NULL,'36'),('8DFSDFSDFSDFVML33','22','Aloe Green',NULL,'37'),('6HM1111EFVL335332','22','Classic Silver',NULL,'38'),('4DFHDFKDFDKFJASS3','22','Barcelona Red',NULL,'39'),('74MNMF90ERTUFF91R','22','Silver Metallic',NULL,'40'),('1123FGDSJH7654GFV','21','White','47547','30'),('7FNFN14223KFJHGHG','21','Blue','42333','31'),('5NFJFJFWWNXXNEFH2','22','White','58595','32'),('234HGDCBV76400987','20','Tan','48475','33'),('55749NFHDL3733YYR','18','Sandy Beach','25564','34'),('444FJFHFMZXZCCVMJ','18','Red','100222','33'),('5DDDFKFQWWEEW32P','18','Blue','89383','34'),('2WWWSSDFSJFGK393U','18','Blue Streak','96956','2'); INSERT INTOInventory (INVWholesale, INVRetail, VehID) VALUES('23500','26995','1'), ('34555','39995','2'),('28000','32000','3'), ('28000','32000','4'),('45250','51995','5'), ('44100','50555','6'),('30000','35000','7'), ('49000','55555','8'),('35000','39995','9'), ('32123','36250','10'),('33000','37750','11'), ('29999','34555','12'),('35000','38964','13'), ('50000','55250','14'),('48000','53654','15'), ('48000','53654','16'),('29650','33000','17'), ('47000','51000','18'),('36985','40050','19'), ('30000','34000','20'),('41000','41450','21'), ('51000','56000','22'),('46520','51250','23'), ('55000','59995','24'),('54000','58888','25'); INSERT INTO Invoice (InvoiceDate,InvoiceAmount, InventoryID, CustomerID, EmployeeID) VALUES('2022-3-1','34887','2','91','7'),('2022-3-2','27600','4','112','7'),('2022-3-3','35000','9','133','7'),('2022-3-4','32750','10','149','6'),('2022-3-5','31014','17','169','5'),('2022-4-1','31887','12','111','7'),('2022-4-2','49600','14','119','5'),('2022-4-3','49000','8','33','6'),('2022-4-4','24750','1','10','5'),('2022-4-5','30014','7','55','6'); INSERT INTO PayHistory(PHBeginDate, PHEndDate, PHRate, PHPayType, PHCommission,EmployeeID, PositionID, DealershipID) VALUES('2022-03-01',NULL,'44','H',NULL,'1','2','7111'),('2022-03-01',NULL,'45','H',NULL,'2','2','7111'),('2022-03-01',NULL,'39','H',NULL,'3','2','5626'),('2022-03-01',NULL,'39','H',NULL,'4','2','7111'),('2022-03-01',NULL,'25','C','5','5','1','7111'),('2022-03-01',NULL,'26.5','C','5','6','1','5626'),('2022-02-01','2022-01-31','26','C','4.25','7','1','5626'),('2022-03-01',NULL,'26.5','C','5','7','1','5626'),('2022-03-01',NULL,'55000','S',NULL,'8','3','7111'),('2022-03-01',NULL,'55000','S',NULL,'9','3','5626'),('2022-02-01','2022-12-31','60000','S',NULL,'10','3','7111');INSERT INTO ServiceTicket (VehID, CustID, STTimeIn, STTimeOut,STComments) VALUES ('26','156','2022-03-01 07:30:00','2022-03-0109:30:00',NULL), ('27','62','2022-03-01 08:30:00','2022-03-0114:30:00',NULL), ('28','11','2022-03-03 09:30:00','2022-03-0312:00:00',NULL), ('29','77','2022-03-03 13:30:00','2022-03-0315:30:00',NULL), ('30','104','2022-03-02 09:30:00','2022-03-0215:00:00',NULL), ('31','100','2022-03-04 08:30:00','2022-03-0411:30:00',NULL), ('32','36','2022-03-03 11:30:00','2022-03-0314:30:00',NULL), ('33','4','2022-03-08 13:30:00','2022-03-0816:00:00',NULL), ('24','88','2022-03-19 08:30:00','2022-03-1910:30:00',NULL), ('25','99','2022-03-10 09:30:00','2022-03-1010:00:00',NULL); INSERT INTO ServiceTicketDetails (STDQty,STDComments, STDWarrantyItem, STID, EmployeeID, ServiceID) VALUES('1','10W40 Synthetic','0','10001','1','1'),('1',NULL,'0','10001','1','6'), ('.25','Battery CapReplace','1','10001','2','5'), ('1.25','WheelAlignment','0','10002','6','5'),('1','Passed','0','10002','1','3'),('1','Passed','0','10002','2','4'), ('2','RecallFixes','1','10003','2','5'), ('3','RecallFixes','1','10004','2','5'), ('0.5','Changed SparkPlugs','0','10004','2','5'), ('1',NULL,'0','10004','1','7'),('2.75','Carburetor Fix','0','10005','3','5'),('1','10W40','0','10006','1','1'), ('1',NULL,'0','10006','2','7'),('1',NULL,'0','10006','2','6'), ('1','RadiatorFlush','0','10007','1','5'), ('0.25','BatteryCheck','1','10007','2','5'), ('1.75','TireBalance','0','10008','3','5'), ('2','RecallFixes','1','10009','3','5'), ('1','Passed','0','10010','1','3'),('1','Failed','0','10010','1','4'); INSERT INTO PartsUsed (PUQty,PartID, STDID) VALUES (1,5001,1), (11,5001,5), (8,5007,4),(7,5004,2), (4,5008,4), (2,5008,3), (3,5008,1);
Step 3: Verifying results Here are the data file import resultsfor all the tables after you insert. If you get the same number ofrows returned, chances are you've created your tables correctly. Ifrows do not insert, or you get an error, recheck your tablecreation. If in doubt, we suggest doing a Select * from each Tableto see the data that was or was not inserted. Dealership (5 row(s)affected) Position (3 row(s) affected) Service (8 row(s) affected)Employee (10 row(s) affected) Customer (174 row(s) affected)Manufacturer (6 row(s) affected) Part (11 row(s) affected) Model(13 row(s) affected) Trim (40 row(s) affected) Vehicle (33 row(s)affected) Inventory (25 row(s) affected) Invoice (10 row(s)affected) PayHistory (11 row(s) affected) Service Ticket (10 row(s)affected) ServiceTicketDetails (20 row(s) affected) PartsUsed (7row(s) affected)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply