0% found this document useful (0 votes)
63 views84 pages

Akx DBMS

Pdf

Uploaded by

kmnlopq29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views84 pages

Akx DBMS

Pdf

Uploaded by

kmnlopq29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 84

202030402 Akshat Mistry 12202040501006

DATABASE MENEGEMENT SYSTEM


FILE
Name : Nensi Chavda
Semester : 3
Enroll. No. : 12202040501011
Batch : 1A04
Dept. : computer Engineering

Practical 1: Creating and Manipulating


Database object and Applying
Constraints (DDL)

a ) Tables are created and insert all data .


CREATE TABLE `contacts` (
`contact_id` int(11) NOT NULL,
`firstname` varchar(255) NOT NULL,
`lastname` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`phone` varchar(20) DEFAULT NULL,
`customer_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

1
DATABASE MANAGEMENT SYSTEM - 202040302
INSERT INTO `contacts` (`contact_id`, `firstname`, `lastname`, `email`, `phone`, `customer_id`)
VALUES
(1, 'Flor', 'Stone', '[email protected]', '+1 317 123 4104', 1),
(2, 'Lavera', 'Emerson', '[email protected]', '+1 317 123 4111', 2),
(3, 'Fern', 'Head', '[email protected]', '+1 812 123 4115', 3),
(4, 'Shyla', 'Ortiz', '[email protected]', '+1 317 123 4126', 4),
(5, 'Jeni', 'Levy', '[email protected]', '+1 812 123 4129', 5),
(6, 'Matthias', 'Hannah', '[email protected]', '+1 219 123 4136', 6),
(7, 'Matthias', 'Cruise', '[email protected]', '+1 219 123 4138', 7),
(8, 'Meenakshi', 'Mason', '[email protected]', '+1 317 123 4141', 8),
(9, 'Christian', 'Cage', '[email protected]', '+1 219 123 4142', 9),
(10, 'Charlie', 'Sutherland', '[email protected]', '+1 317 123 4146', 10),
(11, 'Charlie', 'Pacino', '[email protected]', '+1 812 123 4150', 11),
(12, 'Guillaume', 'Jackson', '[email protected]', '+1 812 123 4151', 12),
(13, 'Daniel', 'Costner', '[email protected]', '+1 812 123 4153', 13),
(14, 'Dianne', 'Derek', '[email protected]', '+1 812 123 4157', 14),
(15, 'Geraldine', 'Schneider', '[email protected]', '+1 313 123 4159', 15),
(16, 'Geraldine', 'Martin', '[email protected]', '+1 313 123 4160', 16),
(17, 'Guillaume', 'Edwards', '[email protected]', '+1 616 123 4162', 17),
(18, 'Maurice', 'Mahoney', '[email protected]', '+1 616 123 4181', 18),
(19, 'Maurice', 'Hasan', '[email protected]', '+1 517 123 4191', 19),
(20, 'Diane', 'Higgins', '[email protected]', '+1 517 123 4199', 20),
(21, 'Dianne', 'Sen', '[email protected]', '+1 517 123 4201', 21),
(22, 'Maurice', 'Daltrey', '[email protected]', '+1 517 123 4206', 22),
(23, 'Tess', 'Roth', '[email protected]', '+1 313 123 4219', 23),
(24, 'Ka', 'Kaufman', '[email protected]', '+1 313 123 4222', 24),
(25, 'Sharyl', 'Montoya', '[email protected]', '+1 517 123 4225', 25),
(26, 'Daniel', 'Glass', '[email protected]', '+1 313 123 4226', 26),
(27, 'Rena', 'Arnold', '[email protected]', '+1 517 123 4228', 27),
(28, 'Arlyne', 'Ingram', '[email protected]', '+1 313 123 4230', 28),
(29, 'Willie', 'Barrera', '[email protected]', '+1 616 123 4234', 29),
(30, 'Mireya', 'Cochran', '[email protected]', '+1 313 123 4242', 30),
(31, 'Marlene', 'Odom', '[email protected]', '+1 616 123 4245', 31),
(32, 'Jaclyn', 'Atkinson', '[email protected]', '+1 313 123 4248', 32),

2
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(33, 'Al', 'Schultz', '[email protected]', '+1 517 123 4253', 33),
(34, 'Felicitas', 'Riley', '[email protected]', '+1 313 123 4255', 34),
(35, 'Cora', 'Calhoun', '[email protected]', '+1 313 123 4263', 35),
(36, 'Trula', 'Buckley', '[email protected]', '+1 517 123 4265', 36),
(37, 'Sasha', 'Wallace', '[email protected]', '+1 319 123 4271', 37),
(38, 'Caitlin', 'Hill', '[email protected]', '+1 515 123 4273', 38),
(39, 'Gino', 'Pickett', '[email protected]', '+1 319 123 4278', 39),
(40, 'Amira', 'Macdonald', '[email protected]', '+1 712 123 4280', 40),
(41, 'Mack', 'Morse', '[email protected]', '+1 319 123 4282', 41),
(42, 'Eboni', 'Jarvis', '[email protected]', '+1 319 123 4288', 42),
(43, 'Gabrielle', 'Dennis', '[email protected]', '+1 515 123 4290', 43),
(44, 'Classie', 'Norris', '[email protected]', '+1 319 123 4301', 44),
(45, 'Khalilah', 'Holman', '[email protected]', '+1 745 123 4306', 45),
(46, 'Isreal', 'Rose', '[email protected]', '+1 414 123 4307', 46),
(47, 'Verena', 'Hopper', '[email protected]', '+1 414 123 4308', 47),
(48, 'Audie', 'Flores', '[email protected]', '+1 608 123 4309', 48),
(49, 'Gertrude', 'Cooke', '[email protected]', '+1 608 123 4318', 49),
(50, 'Princess', 'Kane', '[email protected]', '+1 414 123 4323', 50),
(51, 'Jacinta', 'Faulkner', '[email protected]', '+1 414 123 4324', 51),
(52, 'Lashon', 'Wall', '[email protected]', '+1 414 123 4328', 52),
(53, 'Corliss', 'Mcneil', '[email protected]', '+1 608 123 4332', 53),
(54, 'Brock', 'Webb', '[email protected]', '+1 608 123 4344', 54),
(55, 'Melany', 'Mcmahon', '[email protected]', '+1 414 123 4347', 55),
(56, 'Rogelio', 'Kirby', '[email protected]', '+1 414 123 4348', 56),
(57, 'Wallace', 'Dillard', '[email protected]', '+1 414 123 4350', 57),
(58, 'Gia', 'Boyle', '[email protected]', '+1 745 123 4367', 58),
(59, 'Tennie', 'Gay', '[email protected]', '+1 414 123 4369', 59),
(60, 'Ophelia', 'Hurst', '[email protected]', '+1 715 123 4372', 60),
(61, 'Ciara', 'Flowers', '[email protected]', '+1 414 123 4373', 61),
(62, 'Birgit', 'Stephenson', '[email protected]', '+1 608 123 4374', 62), (63,
'Shameka', 'Spencer', '[email protected]', '+1 414 123 4376', 63),
(64, 'Alysa', 'Kane', '[email protected]', '+1 608 123 4378', 64),
(65, 'Fransisca', 'Reeves', '[email protected]', '+1 414 123 4381', 65),
(66, 'Jessika', 'Merritt', '[email protected]', '+1 612 123 4397', 66),

3
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(67, 'Agustina', 'Conner', '[email protected]', '+1 612 123 4399', 67),
(68, 'Roxanna', 'Wade', '[email protected]', '+1 612 123 4408', 68),
(69, 'Virgie', 'Mays', '[email protected]', '+1 612 123 4417', 69),
(70, 'Trang', 'Mcconnell', '[email protected]', '+1 612 123 4419', 70),
(71, 'Nada', 'West', '[email protected]', '+1 507 123 4421', 71),
(72, 'Catherina', 'Haney', '[email protected]', '+1 218 123 4429', 72),
(73, 'Harriette', 'Melton', '[email protected]', '+1 612 123 4434', 73),
(74, 'Willette', 'Rodgers', '[email protected]', '+1 315 123 4442', 74),
(75, 'Calandra', 'Williamson', '[email protected]', '+1 315 123 4447', 75),
(76, 'Tamatha', 'Delgado', '[email protected]', '+1 716 123 4457', 76),
(77, 'Felix', 'Ferguson', '[email protected]', '+1 518 123 4459', 77),
(78, 'Elwood', 'Hampton', '[email protected]', '+1 518 123 4464', 78),
(79, 'Josh', 'Roach', '[email protected]', '+1 518 123 4474', 79),
(80, 'Luanna', 'Scott', '[email protected]', '+1 914 123 4494', 80),
(81, 'Meryl', 'Cole', '[email protected]', '+1 518 123 4496', 81),
(82, 'Jannet', 'Elliott', '[email protected]', '+1 716 123 4575', 82),
(83, 'Fae', 'Glenn', '[email protected]', '+1 914 123 4578', 83),
(84, 'Francisco', 'Cummings', '[email protected]', '+1 315 123 4597', 84),
(85, 'Ermelinda', 'Benton', '[email protected]', '+1 716 123 4599', 85),
(86, 'Lasonya', 'Beard', '[email protected]', '+1 716 123 4605', 86),
(87, 'Rayna', 'Tran', '[email protected]', '+1 518 123 4617', 87),
(88, 'Annice', 'Boyer', '[email protected]', '+1 518 123 4618', 88),
(89, 'Ja', 'Whitfield', '[email protected]', '+1 914 123 4619', 89),
(90, 'Jaime', 'Lester', '[email protected]', '+1 518 123 4624', 90),
(91, 'Charlsie', 'Lindsey', '[email protected]', '+1 215 123 4644', 91),
(92, 'Jannette', 'Henry', '[email protected]', '+1 610 123 4657', 92),
(93, 'Margart', 'Mccall', '[email protected]', '+1 412 123 4662', 93),
(94, 'Twanna', 'Cleveland', '[email protected]', '+1 814 123 4663', 94),
(95, 'Bronwyn', 'Horn', '[email protected]', '+1 610 123 4664', 95),
(96, 'Jon', 'Petersen', '[email protected]', '+1 610 123 4667', 96),
(97, 'Denny', 'Daniel', '[email protected]', '+1 610 123 4669', 97),
(98, 'Avis', 'Moore', '[email protected]', '+1 717 123 4674', 98),
(99, 'Eden', 'Burke', '[email protected]', '+1 215 123 4676', 99), (100,
'Elisha', 'Lloyd', '[email protected]', '+1 412 123 4681', 100);
4
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

CREATE TABLE `countries` (


`country_id` char(2) NOT NULL,
`countryname` varchar(40) NOT NULL,
`region_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `countries` (`country_id`, `countryname`, `region_id`) VALUES


('AR', 'Argentina', 2),
('AU', 'Australia', 3),
('BE', 'Belgium', 1),
('BR', 'Brazil', 2),
('CA', 'Canada', 2),
('CH', 'Switzerland', 1),
('CN', 'China', 3),
('DE', 'Germany', 1),
('DK', 'Denmark', 1),
('EG', 'Egypt', 4),
('FR', 'France', 1),
('IL', 'Israel', 4),
('IN', 'India', 3),
('IT', 'Italy', 1),
('JP', 'Japan', 3),
('KW', 'Kuwait', 4),
('ML', 'Malaysia', 3),
('MX', 'Mexico', 2),
('NG', 'Nigeria', 4),
('NL', 'Netherlands', 1),
('SG', 'Singapore', 3),
('UK', 'United Kingdom', 1),
('US', 'United States of America', 2),
('ZM', 'Zambia', 4),
('ZW', 'Zimbabwe', 4);

5
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
CREATE TABLE `customers` (
`customer_id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`address` varchar(255) DEFAULT NULL,
`website` varchar(255) DEFAULT NULL,
`creditlimit` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `customers` (`customer_id`, `name`, `address`, `website`, `creditlimit`) VALUES


(32, 'Global Partners', '1135 Catherine St, Ann Arbor, MI', 'http://www.globalp.com', 400),
(39, 'Lear', '2115 N Towne Ln Ne, Cedar Rapids, IA', 'http://www.lear.com', 500),
(43, 'Facebook', '5112 Sw 9Th St, Des Moines, IA', 'http://www.facebook.com', 500),
(46, 'Supervalu', '8989 N Port Washington Rd, Milwaukee, WI', 'http://www.supervalu.com', 500),
(49, 'NextEra Energy', '4715 Sprecher Rd, Madison, WI', 'http://www.nexteraenergy.com', 600),
(52, 'PG&E Corp.', '8600 W National Ave, Milwaukee, WI', 'http://www.pge.com', 700),
(55, 'Goodyear Tire & Rubber', '600 N Broadway Fl 1, Milwaukee, WI',
'http://www.goodyear.com', 700),
(59, 'Micron Technology', '411 E Wisconsin Ave # 2550,
Milwaukee, WI', 'http://www.micron.com', 700),
(62, 'ConAgra Foods', '122 E Dayton St, Madison, WI', 'http://www.conagrafoods.com', 900), (63,
'Sempra Energy', '633 S Hawley Rd, Milwaukee, WI', 'http://www.sempra.com', 900),
(66, 'Bank of New York Mellon Corp.', '666 22Nd Ave Ne, Minneapolis, MN',
'http://www.bnymellon.com', 1200),
(71, 'Genuine Parts', '200 1St St Sw, Rochester, MN', 'http://www.genpt.com', 1200),
(75, 'Omnicom Group', '2134 W Genesee St, Syracuse, NY', 'http://www.omnicomgroup.com', 1200),
(78, 'Precision Castparts', '726 Union St, Hudson, NY', 'http://www.precast.com', 1200),
(79, 'Monsanto', '137 Lark St, Albany, NY', 'http://www.monsanto.com', 1200),
(83, 'National Oilwell Varco', '1 Palisade Ave Fl 2, Yonkers, NY', 'http://www.nov.com', 1200),
(86, 'Marriott International', 'Po Box 2152, Buffalo, NY', 'http://www.marriott.com', 1200), (88,
'Walmart', '1790 Grand Blvd, Schenectady, NY', 'http://www.walmart.com', 1200),
(89, 'Exxon Mobil', '7 Ingelside Ln, White Plains, NY', 'http://www.exxonmobil.com', 1200),
(90, 'Apple', '18 Glenridge Rd, Schenectady, NY', 'http://www.apple.com', 1200),
(91, 'Berkshire Hathaway', '6432 Rising Sun Ave, Philadelphia, PA',
'http://www.berkshirehathaway.com', 1200),
(92, 'McKesson', 'Rr 10, Reading, PA', 'http://www.mckesson.com', 1200),

6
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(93, 'UnitedHealth Group', '2455 Rose Garden Rd, Pittsburgh, PA',
'http://www.unitedhealthgroup.com', 1200),
(94, 'CVS Health', '1812 Timberline Rd, Altoona, PA', 'http://www.cvshealth.com', 1200),
(95, 'General Motors', '141 Schiller St, Reading, PA', 'http://www.gm.com', 1200),
(96, 'Ford Motor', '1126 Pawlings Rd, Norristown, PA', 'http://www.ford.com', 1200),
(97, 'AT&T', '55 Church Hill Rd, Reading, PA', 'http://www.att.com', 1200),
(98, 'General Electric', '354 N Prince St, Lancaster, PA', 'http://www.ge.com', 1200),
(99, 'AmerisourceBergen', '115 Chestnut St, Philadelphia, PA',
'http://www.amerisourcebergen.com', 1400),
(100, 'Verizon', '2899 Grand Ave, Pittsburgh, PA', 'http://www.verizon.com', 1400),
(101, 'Chevron', 'Po Box 39, Indiana, PA', 'http://www.chevron.com', 1400),
(102, 'Costco', '1604 Broadway Ave, Pittsburgh, PA', 'http://www.costco.com', 1400),
(103, 'Fannie Mae', '4734 Liberty Ave, Pittsburgh, PA', 'http://www.fanniemae.com', 1400),
(104, 'Kroger', '21 Thornwood Rd, Harrisburg, PA', 'http://www.thekrogerco.com', 1400),
(105, 'Amazon.com', '3725 W Lake Rd, Erie, PA', 'http://www.amazon.com', 1400),

(106, 'Walgreens Boots Alliance', '1808 4Th Ave, Altoona, PA',


'http://www.walgreensbootsalliance.com', 1400),
(107, 'HP', 'Station Sq, Pittsburgh, PA', 'http://www.hp.com', 1400),
(108, 'Cardinal Health', '4020 Garden Ave, Erie, PA', 'http://www.cardinal.com', 1400),
(109, 'Express Scripts Holding', '100 N Peach St, Philadelphia, PA', 'http://www.expressscripts.com',
1400),
(110, 'J.P. Morgan Chase', '835 Heister Ln, Reading, PA', 'http://www.jpmorganchase.com', 1400),
(111, 'W.W. Grainger', '378 S Negley Ave, Pittsburgh, PA', 'http://www.grainger.com', 1500),
(112, 'Boeing', '5643 N 5Th St, Philadelphia, PA', 'http://www.boeing.com', 1500),
(113, 'Microsoft', '1401 W Warren Rd, Bradford, PA', 'http://www.microsoft.com', 1500),
(114, 'Bank of America Corp.', '815 Freeport Rd, Pittsburgh, PA',
'http://www.bankofamerica.com', 1500),
(115, 'Wells Fargo', '327 N Washington Ave # 300, Scranton, PA',
'http://www.wellsfargo.com', 1900),
(117, 'Home Depot', '4901 Locust Ln, Harrisburg, PA', 'http://www.homedepot.com', 2300),
(118, 'Citigroup', '3376 Perrysville Ave, Pittsburgh, PA', 'http://www.citigroup.com', 2300),
(119, 'Phillips 66', '220 Penn Ave # 300, Scranton, PA', 'http://www.phillips66.com', 2300),
(121, 'IBM', '522 Swede St, Norristown, PA', 'http://www.ibm.com', 2300),
(122, 'Valero Energy', '7708 City Ave, Philadelphia, PA', 'http://www.valero.com', 2300),
(123, 'Anthem', '1801 Lititz Pike, Lancaster, PA', 'http://www.antheminc.com', 2300),
(124, 'Procter & Gamble', '101 E Olney Ave, Philadelphia, PA', 'http://www.pg.com', 2300),
(125, 'Air Products & Chemicals', '612 Jefferson Ave, Scranton, PA',

7
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
'http://www.airproducts.com', 2300),
(127, 'Alphabet', '36 W 34Th St, Erie, PA', 'http://www.google.com', 2400),
(128, 'Comcast', '1007 Mount Royal Blvd, Pittsburgh, PA',
'http://www.comcastcorporation.com', 2400),
(129, 'Target', '601 Market St, Philadelphia, PA', 'http://www.target.com', 2400),
(132, 'MetLife', '5122 Sinclair Ln, Baltimore, MD', 'http://www.metlife.com', 2400),
(133, 'Archer Daniels Midland', '680 Bel Air Rd, Bel Air, MD', 'http://www.adm.com', 2400),
(135, 'Freddie Mac', '8004 Stansbury Rd, Baltimore, MD', 'http://www.freddiemac.com', 2400),
(136, 'PepsiCo', '10209 Yearling Dr, Rockville, MD', 'http://www.pepsico.com', 2400),
(137, 'United Technologies', '3000 Greenmount Ave, Baltimore, MD', 'http://www.utc.com', 2400),
(139, 'Lowe?s', '1262 Vocke Rd, Cumberland, MD', 'http://www.lowes.com', 2400),
(140, 'UPS', '3314 Eastern Ave, Baltimore, MD', 'http://www.ups.com', 2400),
(142, 'Prudential Financial', '11200 Scaggsville Rd, Laurel, MD',
'http://www.prudential.com', 2400),
(163, 'Charter Communications', '802 North Ave, Pittsburgh, PA', 'http://www.charter.com', 3600),
(177, 'United Continental Holdings', '2904 S Salina St, Syracuse, NY',
'http://www.unitedcontinentalholdings.com', 5000),
(180, 'INTL FCStone', '5344 Haverford Ave, Philadelphia, PA', 'http://www.intlfcstone.com', 5000),
(184, 'Publix Super Markets', '1795 Wu Meng, Muang Chonburi, ', 'http://www.publix.com', 1200),
(187, 'ConocoPhillips', 'Walpurgisstr 69, Munich, ', 'http://www.conocophillips.com', 2400),
(190, '3M', 'Via Frenzy 6903, Roma, ', 'http://www.3m.com', 1200),
(192, 'Exelon', 'Via Luminosa 162, Firenze, ', 'http://www.exeloncorp.com', 500),
(195, 'Applied Materials', 'Via Dolorosa 69, Tellaro, ', 'http://www.appliedmaterials.com', 700),
(200, 'Enterprise Products Partners', 'Via Notoriosa 1949, Firenze, ',
'http://www.enterpriseproducts.com', 2400),
(204, 'Rite Aid', 'Piazza Cacchiatore 23, San Giminiano, ', 'http://www.riteaid.com', 3600),
(206, 'Ally Financial', 'Via Notoriosa 1949, Ventimiglia, ', 'http://www.ally.com', 3600),
(207, 'Northwestern Mutual', '1831 No Wong, Peking, ',
'http://www.northwesternmutual.com', 3600),
(208, 'Tesoro', 'Via Notoriosa 1942, Firenze, ', 'http://www.tsocorp.com', 500),
(212, 'Qualcomm', 'Piazza Svizzera, Milano, ', 'http://www.qualcomm.com', 500), (216,
'EMC', 'Via Delle Grazie 11, San Giminiano, ', 'http://www.emc.com', 700),
(218, 'Lennar', '1592 Silverado St, Bangalore, Kar', 'http://www.lennar.com', 700),
(220, 'Time Warner Cable', '1597 Legend St, Mysore, Kar', 'http://www.twc.com', 3700),
(223, 'Northrop Grumman', '1606 Sangam Blvd, New Delhi, ',
'http://www.northropgrumman.com', 5000),

8
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(228, 'Kinder Morgan', '1614 Gitanjali Rd, Calcutta, ', 'http://www.kindermorgan.com', 5000),
(231, 'Molina Healthcare', '1617 Crackers St, Bangalore - India, Kar',
'http://www.molinahealthcare.com', 300),
(235, 'Lincoln National', '1622 Roja St, Chennai, Tam', 'http://www.lfg.com', 5000),
(238, 'C.H. Robinson Worldwide', '1628 Pataudi St, New Delhi, ',
'http://www.chrobinson.com', 1900),
(242, 'Synnex', '1647 Suspense St, Cochin, Ker', 'http://www.synnex.com', 500),
(243, 'Hormel Foods', '1648 Anamika St, Cochin, Ker', 'http://www.hormelfoods.com', 500),
(245, 'HollyFrontier', '1656 Veterans Rd, Chennai, Tam', 'http://www.hollyfrontier.com', 2500),
(249, 'PBF Energy', 'Piazza Quattre Stagioni 4, Roma, ', 'http://www.pbfenergy.com', 3700),
(254, 'PayPal Holdings', 'Via Dello Croce 93, Roma, ', 'http://www.paypal.com', 1200), (255,
'Waste Management', 'Via Di Firenze 231, Roma, ', 'http://www.wm.com', 2400),
(259, 'Parker-Hannifin', 'Canale Grande 2, Roma, ', 'http://www.parker.com', 700),
(263, 'Farmers Insurance Exchange', 'Via Dello Croce 93, Tellaro, ',
'http://www.farmers.com', 100),
(266, 'Autoliv', 'Via Delle Capeletti 52, San Giminiano, ', 'http://www.autoliv.com', 400),
(268, 'VF', '1971 Limelight Blvd, Samutprakarn, ', 'http://www.vfc.com', 1200),
(294, 'Corning', 'Pfannenstilstr 13, Egg, ZH', 'http://www.corning.com', 2300),
(301, 'Univar', '1598 Legend St, Bangalore, Kar', 'http://www.univar.com', 5000),
(313, 'Hertz Global Holdings', '1616 Crackers Blvd, Bangalore - India, Kar', 'http://www.hertz.com',
5000),
(314, 'Thrivent Financial for Lutherans', '1617 Crackers St, Bangalore - India, Kar',
'http://www.thrivent.com', 900),
(319, 'BB&T Corp.', '1668 Chong Tao, Beijing, ', 'http://www.bbt.com', 200);

CREATE TABLE `employees` (


`employee_id` int(11) NOT NULL,
`firstname` varchar(255) NOT NULL,
`lastname` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`phone` varchar(50) NOT NULL,
`hiredate` date NOT NULL,
`manager_id` int(11) DEFAULT NULL,
`jobtitle` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

9
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
INSERT INTO `employees` (`employee_id`, `firstname`, `lastname`, `email`, `phone`, `hiredate`,
`manager_id`, `jobtitle`) VALUES
(1, 'Tommy', 'Bailey', '[email protected]', '515.123.4567', '2016-06-17', NULL, 'President'),
(2, 'Jude', 'Rivera', '[email protected]', '515.123.4568', '2016-09-21', 1,
'Administration Vice President'),
(3, 'Blake', 'Cooper', '[email protected]', '515.123.4569', '2016-01-13', 1, 'Administration Vice
President'),
(4, 'Louie', 'Richardson', '[email protected]', '590.423.4567', '2016-01-03', 3,
'Programmer'),
(5, 'Nathan', 'Cox', '[email protected]', '590.423.4568', '2016-05-21', 4,
'Programmer'),
(6, 'Gabriel', 'Howard', '[email protected]', '590.423.4569', '2016-06-25', 4, 'Programmer'),
(7, 'Charles', 'Ward', '[email protected]', '590.423.4560', '2016-02-05', 4, 'Programmer'),
(8, 'Bobby', 'Torres', '[email protected]', '590.423.5567', '2016-02-07', 4, 'Programmer'),
(9, 'Mohammad', 'Peterson', '[email protected]', '515.124.4569', '2016-0817', 2,
'Finance Manager'),
(10, 'Ryan', 'Gray', '[email protected]', '515.124.4169', '2016-08-16', 9, 'Accountant'),
(11, 'Tyler', 'Ramirez', '[email protected]', '515.124.4269', '2016-09-28', 9, 'Accountant'),
(12, 'Elliott', 'James', '[email protected]', '515.124.4369', '2016-09-30', 9, 'Accountant'),
(13, 'Albert', 'Watson', '[email protected]', '515.124.4469', '2016-03-07', 9, 'Accountant'),
(14, 'Elliot', 'Brooks', '[email protected]', '515.124.4567', '2016-12-07', 9, 'Accountant'),
(15, 'Rory', 'Kelly', '[email protected]', '515.127.4561', '2016-12-07', 1, 'Purchasing Manager'),
(16, 'Alex', 'Sanders', '[email protected]', '515.127.4562', '2016-05-18', 15, 'Purchasing Clerk'),
(17, 'Frederick', 'Price', '[email protected]', '515.127.4563', '2016-12-24', 15, 'Purchasing
Clerk'),
(18, 'Ollie', 'Bennett', '[email protected]', '515.127.4564', '2016-07-24', 15, 'Purchasing Clerk'),
(19, 'Louis', 'Wood', '[email protected]', '515.127.4565', '2016-11-15', 15, 'Purchasing Clerk'),
(20, 'Dexter', 'Barnes', '[email protected]', '515.127.4566', '2016-08-10', 15, 'Purchasing
Clerk'),
(46, 'Ava', 'Sullivan', '[email protected]', '011.44.1344.429268', '2016-10-01', 1, 'Sales
Manager'),
(47, 'Ella', 'Wallace', '[email protected]', '011.44.1344.467268', '2016-01-05', 1, 'Sales
Manager'),
(48, 'Jessica', 'Woods', '[email protected]', '011.44.1344.429278', '2016-03-10', 1, 'Sales
Manager'),
(49, 'Isabella', 'Cole', '[email protected]', '011.44.1344.619268', '2016-10-15', 1, 'Sales
Manager'),
(50, 'Mia', 'West', '[email protected]', '011.44.1344.429018', '2016-01-29', 1, 'Sales Manager'),

10
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(56, 'Evie', 'Harrison', '[email protected]', '011.44.1344.486508', '2016-11-23', 46, 'Sales
Representative'),
(57, 'Scarlett', 'Gibson', '[email protected]', '011.44.1345.429268', '2016-01-30', 47, 'Sales
Representative'),
(58, 'Ruby', 'Mcdonald', '[email protected]', '011.44.1345.929268', '2016-03-04', 47, 'Sales
Representative'),
(101, 'Annabelle', 'Dunn', '[email protected]', '515.123.4444', '2016-09-17', 2,
'Administration Assistant'),
(102, 'Emma', 'Perkins', '[email protected]', '515.123.5555', '2016-02-17', 1, 'Marketing
Manager'),
(103, 'Amelie', 'Hudson', '[email protected]', '603.123.6666', '2016-08-17', 102, 'Marketing
Representative'),
(104, 'Harper', 'Spencer', '[email protected]', '515.123.7777', '2016-06-07', 2, 'Human
Resources Representative'),
(105, 'Gracie', 'Gardner', '[email protected]', '515.123.8888', '2016-06-07', 2, 'Public
Relations Representative'),
(106, 'Rose', 'Stephens', '[email protected]', '515.123.8080', '2016-06-07', 2, 'Accounting
Manager'),
(107, 'Summer', 'Payne', '[email protected]', '515.123.8181', '2016-06-07', 106, 'Public
Accountant');

CREATE TABLE `inventories` (


`product_id` int(11) NOT NULL,
`warehouse_id` int(11) NOT NULL,
`quantity` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `inventories` (`product_id`, `warehouse_id`, `quantity`) VALUES


(2, 9, 23),
(3, 9, 35),
(4, 9, 35),
(5, 9, 36),
(6, 9, 36),
(7, 9, 36),
(8, 9, 36),
(9, 9, 36),
(11, 9, 37),
11
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(12, 9, 37),
(13, 9, 37),
(14, 9, 38),
(15, 9, 41),
(17, 9, 3),
(18, 9, 3),
(19, 9, 3),
(20, 9, 4),
(21, 9, 4),
(27, 9, 5),
(29, 9, 6),
(30, 9, 6),
(31, 9, 7),
(32, 9, 7),
(34, 9, 8),
(46, 9, 6),
(47, 9, 0),
(54, 9, 33),
(62, 9, 32),
(63, 9, 33),
(67, 9, 34),
(68, 9, 34),
(69, 9, 35),
(70, 9, 35),
(71, 9, 35),
(72, 9, 35),
(73, 9, 27),
(74, 9, 27),
(76, 9, 28), (78, 9, 29),
(79, 9, 29),
(80, 9, 29),
(84, 9, 33),
(87, 9, 35),
(88, 9, 7),
12
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(89, 9, 8),
(90, 9, 8),
(91, 9, 22),
(98, 9, 32),
(101, 9, 3),
(102, 9, 36),
(103, 9, 5),
(105, 9, 6),
(106, 9, 6),
(107, 9, 6),
(108, 9, 6),
(109, 9, 6),
(110, 9, 7),
(114, 9, 8),
(115, 9, 9),
(116, 9, 9),
(117, 9, 9),
(119, 9, 10),
(120, 9, 10),
(121, 9, 10),
(122, 9, 11),
(123, 9, 11),
(124, 9, 11),
(125, 9, 11),
(126, 9, 12),
(128, 9, 12), (129, 9, 12),
(132, 9, 13),
(133, 9, 13),
(136, 9, 14),
(137, 9, 15),
(138, 9, 16),
(141, 9, 18),
(142, 9, 19),
(159, 9, 15),
13
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(160, 9, 21),
(161, 9, 36),
(163, 9, 35),
(166, 9, 54),
(174, 9, 74),
(175, 9, 74),
(182, 9, 110),
(184, 9, 111),
(185, 9, 111),
(188, 9, 119),
(189, 9, 119),
(190, 9, 120),
(191, 9, 120),
(193, 9, 121),
(195, 9, 122),
(196, 9, 122),
(198, 9, 122),
(199, 9, 123),
(200, 9, 123),
(201, 9, 124),
(203, 9, 124),
(204, 9, 125),
(205, 9, 125), (207, 9, 109),
(210, 8, 122),
(210, 9, 110),
(211, 8, 123),
(211, 9, 111),
(212, 8, 123),
(212, 9, 111),
(214, 8, 124),
(214, 9, 112),
(216, 8, 125),
(216, 9, 113),
(217, 8, 125),
14
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(217, 9, 113),
(218, 8, 126),
(220, 8, 149),
(221, 8, 150),
(222, 8, 150),
(223, 8, 151),
(229, 8, 123),
(230, 8, 124),
(231, 8, 124),
(232, 8, 124),
(233, 8, 124),
(234, 8, 124),
(235, 8, 125),
(241, 8, 121),
(242, 8, 121),
(243, 8, 121),
(245, 8, 137),
(254, 8, 136),
(255, 8, 136),
(256, 8, 136), (257, 8, 136),
(258, 8, 136),
(259, 8, 137),
(260, 8, 137),
(263, 8, 137),
(264, 8, 137),
(269, 8, 178),
(270, 8, 178),
(271, 8, 183),
(272, 8, 184),
(273, 8, 156),
(274, 8, 160),
(276, 8, 187),
(277, 8, 187),
(278, 8, 188),
15
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(280, 8, 154),
(281, 8, 167),
(283, 8, 194),
(284, 8, 268),
(285, 8, 176), (286,
8, 177);

CREATE TABLE `locations` (


`location_id` int(11) NOT NULL,
`address` varchar(255) NOT NULL,
`postalcode` varchar(20) DEFAULT NULL,
`city` varchar(50) DEFAULT NULL,
`state` varchar(50) DEFAULT NULL,
`country_id` char(2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `locations` (`location_id`, `address`, `postalcode`, `city`, `state`, `country_id`) VALUES
(
1, '1297 Via Cola di Rie', '00989', 'Roma', NULL, 'IT'),
(2, '93091 Calle della Testa', '10934', 'Venice', NULL, 'IT'),
(3, '2017 Shinjuku-ku', '1689', 'Tokyo', 'Tokyo Prefecture', 'JP'),
(4, '9450 Kamiya-cho', '6823', 'Hiroshima', NULL, 'JP'),
(5, '2014 Jabberwocky Rd', '26192', 'Southlake', 'Texas', 'US'),
(6, '2011 Interiors Blvd', '99236', 'South San Francisco', 'California', 'US'),
(7, '2007 Zagora St', '50090', 'South Brunswick', 'New Jersey', 'US'),
(8, '2004 Charade Rd', '98199', 'Seattle', 'Washington', 'US'),
(9, '147 Spadina Ave', 'M5V 2L7', 'Toronto', 'Ontario', 'CA'),
(10, '6092 Boxwood St', 'YSW 9T2', 'Whitehorse', 'Yukon', 'CA'),
(11, '40-5-12 Laogianggen', '190518', 'Beijing', NULL, 'CN'),
(12, '1298 Vileparle (E)', '490231', 'Bombay', 'Maharashtra', 'IN'),
(13, '12-98 Victoria Street', '2901', 'Sydney', 'New South Wales', 'AU'),
(14, '198 Clementi North', '540198', 'Singapore', NULL, 'SG'),
(15, '8204 Arthur St', NULL, 'London', NULL, 'UK'),
(16, 'Magdalen Centre, The Oxford Science Park', 'OX9 9ZB', 'Oxford', 'Oxford', 'UK'),
16
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(17, '9702 Chester Road', '09629850293', 'Stretford', 'Manchester', 'UK'),
(18, 'Schwanthalerstr. 7031', '80925', 'Munich', 'Bavaria', 'DE'),
(19, 'Rua Frei Caneca 1360 ', '01307-002', 'Sao Paulo', 'Sao Paulo', 'BR'),
(20, '20 Rue des Corps-Saints', '1730', 'Geneva', 'Geneve', 'CH'),
(21, 'Murtenstrasse 921', '3095', 'Bern', 'BE', 'CH'),
(22, 'Pieter Breughelstraat 837', '3029SK', 'Utrecht', 'Utrecht', 'NL'),
(23, 'Mariano Escobedo 9991', '11932', 'Mexico City', 'Distrito Federal,', 'MX');

CREATE TABLE `orders` (


`order_id` int(11) NOT NULL,
`status` varchar(20) NOT NULL,
`customer_id` int(11) DEFAULT NULL,
`salesman_id` int(11) DEFAULT NULL,
`order_date` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `orders` (`order_id`, `status`, `customer_id`, `salesman_id`, `order_date`) VALUES


(1, 'Pending', 4, 56, '2016-09-15'),
(2, 'Shipped', 4, NULL, '2015-04-26'),
(3, 'Shipped', 5, NULL, '2017-04-26'),
(4, 'Shipped', 8, 59, '2016-04-09'),
(5, 'Canceled', 5, 56, '2016-04-09'),
(6, 'Shipped', 6, NULL, '2015-04-09'),
(7, 'Shipped', 7, NULL, '2017-02-15'),
(8, 'Shipped', 8, NULL, '2017-02-14'),
(9, 'Shipped', 9, NULL, '2017-02-14'),
(26, 'Shipped', 46, 62, '2016-08-16'),
(28, 'Canceled', 6, 57, '2016-08-15'),
(41, 'Shipped', 9, 59, '2016-05-11'),
(43, 'Shipped', 47, 62, '2016-05-02'),
(44, 'Pending', 2, 55, '2016-02-20'),
(53, 'Shipped', 48, 62, '2016-09-29'),
(79, 'Shipped', 2, 64, '2016-12-14'),
17
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(80, 'Shipped', 3, 64, '2016-12-13'),
(81, 'Shipped', 49, 62, '2016-12-13'),
(82, 'Shipped', 44, 60, '2016-12-03'),
(83, 'Shipped', 16, 62, '2016-12-02'),
(87, 'Canceled', 7, 57, '2016-12-01'),
(93, 'Shipped', 17, 62, '2016-08-27'), (94,
'Shipped', 1, 62, '2017-10-27'),
(101, 'Pending', 3, 55, '2016-01-03'),
(102, 'Shipped', 45, 61, '2016-12-20'),
(105, 'Pending', 1, 54, '2016-11-17');

CREATE TABLE `order_items` (


`order_id` int(11) NOT NULL,
`item_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`quantity` int(11) NOT NULL,
`unit_price` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `order_items` (`order_id`, `item_id`, `product_id`, `quantity`,


`unit_price`) VALUES
(1, 1, 137, 116, 470),
(1, 2, 78, 77, 687),
(2, 1, 43, 111, 299),
(2, 9, 200, 75, 621),
(3, 1, 24, 111, 67),
(3, 2, 56, 65, 17),
(4, 1, 280, 47, 150),
(4, 8, 18, 116, 799),
(5, 1, 149, 70, 283),
(6, 1, 199, 67, 648),
(6, 7, 7, 119, 681),

18
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(7, 1, 227, 74, 305),
(8, 1, 87, 92, 760),
(8, 9, 268, 148, 48),
(9, 1, 108, 139, 850),
(10, 1, 145, 118, 287),
(11, 1, 96, 113, 142),
(12, 1, 191, 41, 574),
(13, 1, 84, 46, 440),
(14, 1, 129, 98, 735),
(15, 1, 287, 60, 330),
(16, 1, 166, 70, 1639),
(17, 1, 149, 51, 283),
(18, 1, 213, 105, 1470),
(19, 1, 38, 53, 1200),
(20, 1, 126, 105, 641),
(21, 1, 36, 79, 1300),
(22, 1, 83, 44, 830),
(23, 1, 202, 104, 714),
(24, 1, 121, 129, 722),
(25, 1, 43, 109, 299),
(26, 1, 200, 114, 621),
(27, 1, 71, 38, 660),
(28, 1, 31, 61, 444), (29, 1,
7, 38, 681),
(30, 1, 235, 70, 42),
(31, 1, 101, 68, 636),
(32, 1, 251, 83, 338),
(33, 1, 55, 93, 151),
(34, 1, 185, 141, 874),
(35, 1, 174, 133, 798), (36, 1,
204, 45, 687),
(37, 1, 35, 150, 1315),
(38, 1, 71, 90, 660),
(39, 1, 186, 116, 1450),
19
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(40, 1, 141, 106, 420),
(41, 1, 268, 80, 48),
(42, 1, 34, 45, 418),
(43, 1, 67, 74, 863),
(44, 1, 220, 118, 760),
(45, 1, 74, 43, 702),
(46, 1, 120, 51, 892),
(47, 1, 178, 73, 2000),
(48, 1, 165, 46, 1667),
(49, 1, 172, 104, 358),
(50, 1, 215, 49, 830),
(51, 1, 21, 34, 750),
(52, 1, 235, 123, 42),
(53, 1, 100, 130, 98),
(54, 1, 208, 73, 1200),
(55, 1, 102, 127, 2043),
(56, 1, 84, 70, 440),
(57, 1, 224, 75, 350),
(58, 1, 64, 55, 526),
(59, 1, 178, 101, 2000),
(60, 1, 205, 74, 650),
(61, 1, 174, 114, 798),
(62, 1, 188, 130, 482),
(63, 1, 70, 72, 711),
(64, 1, 199, 61, 648),
(65, 1, 280, 104, 150),
(66, 1, 77, 143, 696),
(67, 1, 287, 61, 330),
(68, 1, 163, 98, 1900),
(69, 1, 206, 57, 4139),
(70, 1, 185, 146, 874),
(70, 7, 32, 132, 470),
(71, 1, 19, 146, 1704),
(72, 1, 129, 101, 735),
20
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(73, 1, 245, 120, 1699),
(73, 5, 192, 124, 520),
(74, 1, 104, 97, 84),
(74, 7, 27, 92, 801),
(75, 1, 58, 73, 785),
(75, 11, 6, 128, 850),
(76, 1, 109, 92, 714),
(76, 10, 95, 106, 110), (77, 1, 203, 65, 671),
(77, 5, 271, 148, 550),
(78, 1, 92, 147, 2200),
(79, 1, 285, 145, 340),
(80, 1, 213, 63, 1470),
(81, 1, 128, 133, 742),
(81, 7, 79, 127, 660),
(82, 1, 91, 42, 2260),
(82, 9, 284, 138, 55),
(83, 1, 264, 35, 89),
(83, 8, 174, 117, 798),
(84, 1, 106, 137, 609),
(84, 6, 131, 34, 280),
(85, 1, 155, 114, 589),
(86, 1, 202, 46, 714),
(87, 1, 47, 123, 2377),
(87, 11, 271, 58, 550),
(88, 1, 278, 139, 678),
(89, 1, 247, 45, 340),
(90, 1, 65, 84, 1200),
(90, 8, 92, 49, 2200),
(91, 1, 122, 89, 723),
(91, 11, 226, 77, 310),
(92, 1, 208, 114, 1200),
(93, 1, 257, 70, 85),
(93, 5, 121, 141, 722),
(94, 1, 255, 38, 91),
21
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(94, 9, 12, 33, 825),
(95, 1, 52, 138, 1677),
(96, 1, 260, 34, 268),
(97, 1, 110, 39, 3193),
(98, 1, 66, 104, 400), (99, 1, 95, 66, 110),
(99, 9, 17, 144, 699),
(100, 1, 280, 70, 150),
(101, 1, 17, 47, 699),
(102, 1, 196, 69, 1100),
(102, 3, 247, 149, 340),
(103, 1, 6, 117, 850),
(104, 1, 129, 74, 735),
(104, 7, 178, 145, 2000),
(105, 1, 31, 116, 444), (105, 6,
183, 79, 900);

CREATE TABLE `products` (


`product_id` int(11) NOT NULL,
`productname` varchar(255) NOT NULL,
`description` varchar(2000) DEFAULT NULL,
`standardcost` int(11) DEFAULT NULL,
`listprice` int(11) DEFAULT NULL,
`category_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `products` (`product_id`, `productname`, `description`, `standardcost`, `listprice`,


`category_id`) VALUES
(2, 'Intel Xeon E5-2697 V4', 'Speed:2.3GHz,Cores:18,TDP:145W', 2144, 2555, 1),
(4, 'AMD 100-505989', 'Chipset:FirePro W9100,Memory:32GBCore Clock:930MHz', 2129, 2700, 2),
(5, 'PNY VCQK6000-PB', 'Chipset:Quadro K6000,Memory:12GBCore Clock:902MHz', 1740, 2291, 2),
(6, 'Zotac ZT-P10810A-10P', 'Chipset:GeForce GTX 1080
Ti,Memory:11GBCore
Clock:1.48GHz', 702, 850, 2),
(8, 'Intel Xeon E5-1650 V4', 'Speed:3.6GHz,Cores:6,TDP:140W', 535, 602, 1),

22
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(9, 'Intel Xeon E5-2640 V4', 'Speed:2.4GHz,Cores:10,TDP:90W', 739, 900, 1),
(11, 'PNY VCQP5000-PB', 'Chipset:Quadro P5000,Memory:16GBCore Clock:1.61GHz', 1602, 2015,
2),
(12, 'Gigabyte GV-N108TAORUSX W-11GD', 'Chipset:GeForce GTX 1080 Ti,Memory:11GBCore
Clock:1.63GHz', 596, 825, 2),
(16, 'Intel Core i7-6900K', 'Speed:3.2GHz,Cores:8,TDP:140W', 793, 890, 1),
(19, 'Intel Core i7-6950X (OEM/Tray)', 'Speed:3.0GHz,Cores:10,TDP:140W', 1480, 1704, 1), (27,
'Intel Core i7-3960X Extreme Edition', 'Speed:3.3GHz,Cores:6,TDP:130W', 573, 801, 1),
(45, 'Intel Xeon E5-2685 V3 (OEM/Tray)', 'Speed:2.6GHz,Cores:12,TDP:120W', 2012, 2502, 1),
(46, 'Intel Xeon E5-2695 V3 (OEM/Tray)', 'Speed:2.3GHz,Cores:14,TDP:120W', 1925, 2432, 1), (47,
'Intel Xeon E5-2697 V2', 'Speed:2.7GHz,Cores:12,TDP:130W', 2102, 2377, 1),
(48, 'AMD FirePro S7000', 'Chipset:FirePro S7000,Memory:4GBCore Clock:950MHz', 936, 1219, 2),
(51, 'Intel Xeon E5-2695 V4', 'Speed:2.1GHz,Cores:18,TDP:120W', 1780, 2270, 1),
(52, 'Intel Xeon E5-2670 V3', 'Speed:2.3GHz,Cores:12,TDP:120W', 1454, 1677, 1),
(53, 'Intel Core 2 Extreme QX6800', 'Speed:2.93GHz,Cores:4,TDP:100W', 788, 1004, 1),
(54, 'Intel Xeon E5-1660 V3 (OEM/Tray)', 'Speed:3.0GHz,Cores:8,TDP:140W', 915, 1020, 1),
(59, 'Intel Core i7-5960X (OEM/Tray)', 'Speed:3.0GHz,Cores:8,TDP:140W', 880, 978, 1),
(69, 'Intel Core i7-7820X', 'Speed:3.6GHz,Cores:8,TDP:140W', 511, 679, 1),
(70, 'Intel Xeon E5-2687W', 'Speed:3.1GHz,Cores:8,TDP:150W', 581, 711, 1),
(71, 'Intel Core i7-3930K', 'Speed:3.2GHz,Cores:6,TDP:130W', 509, 660, 1),
(72, 'Intel Xeon E5-2630 V3 (OEM/Tray)', 'Speed:2.4GHz,Cores:8,TDP:85W', 422, 590, 1),
(73, 'Intel Core i7-4770K', 'Speed:3.5GHz,Cores:4,TDP:84W', 714, 799, 1),
(74, 'Intel Xeon E5-2680 V2', 'Speed:2.8GHz,Cores:10,TDP:115W', 568, 702, 1),
(75, 'Intel Core i7-4930K', 'Speed:3.4GHz,Cores:6,TDP:130W', 528, 624, 1),
(76, 'Intel Xeon E5-2630 V3', 'Speed:2.4GHz,Cores:8,TDP:85W', 500, 630, 1),
(80, 'Intel Xeon E5-1650 V3', 'Speed:3.5GHz,Cores:6,TDP:140W', 400, 565, 1),
(81, 'Intel Xeon E5-2650 V4', 'Speed:2.2GHz,Cores:12,TDP:105W', 945, 1100, 1),
(82, 'Intel Core i7-6950X', 'Speed:3.0GHz,Cores:10,TDP:140W', 1053, 1500, 1),
(83, 'Asus STRIX-GTX1080TI-O11G-GAMING', 'Chipset:GeForce GTX 1080
Ti,Memory:11GBCore Clock:1.57GHz', 691, 830, 2),
(85, 'Intel Xeon E5-2660 V3 (OEM/Tray)', 'Speed:2.6GHz,Cores:10,TDP:105W', 902, 1275, 1), (91,
'Intel Xeon E5-2695 V2', 'Speed:2.4GHz,Cores:12,TDP:115W', 1794, 2260, 1),
(92, 'Intel Xeon E5-2643 V2 (OEM/Tray)', 'Speed:3.5GHz,Cores:6,TDP:130W', 1940, 2200, 1),
(93, 'Intel Xeon E5-2690 (OEM/Tray)', 'Speed:2.9GHz,Cores:8,TDP:135W', 1888, 2117, 1), (98, 'Intel
Xeon E5-2687W V3', 'Speed:3.1GHz,Cores:10,TDP:160W', 1781, 2065, 1),

23
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(102, 'Intel Xeon E5-2687W V4', 'Speed:3.0GHz,Cores:12,TDP:160W', 1724, 2043, 1),
(105, 'EVGA 12G-P4-3992-KR', 'Chipset:GeForce GTX Titan Z,Memory:12GBCore Clock:732MHz',
2313, 2800, 2),
(106, 'Intel Xeon E5-2640 V2', 'Speed:2.0GHz,Cores:8,TDP:95W', 545, 609, 1),
(108, 'MSI GAMING', 'Chipset:GeForce GTX 780 Ti,Memory:3GBCore Clock:1.02GHz', 753, 850, 2),
(110, 'ATI FirePro W9000', 'Chipset:FirePro W9000,Memory:6GBCore Clock:975MHz', 2786, 3193,
2),
(111, 'Intel Core i7-6900K (OEM/Tray)', 'Speed:3.2GHz,Cores:8,TDP:140W', 620, 827, 1),
(114, 'Zotac ZT-70203-10P', 'Chipset:GeForce GTX 780,Memory:3GBCore Clock:1.01GHz', 580, 821,
2),
(119, 'Intel Xeon E5-2640 V3', 'Speed:2.6GHz,Cores:8,TDP:90W', 668, 900, 1),
(120, 'Intel Core 2 Extreme QX9775', 'Speed:3.2GHz,Cores:4,TDP:150W', 738, 892, 1),
(123, 'ATI FirePro S9150', 'Chipset:FirePro S9150,Memory:16GBCore Clock:900MHz', 2628, 3177, 2),
(124, 'Intel Xeon E5-1650 V4 (OEM/Tray)', 'Speed:3.6GHz,Cores:6,TDP:140W', 453, 595, 1),
(132, 'Intel Core i7-5930K', 'Speed:3.5GHz,Cores:6,TDP:140W', 482, 555, 1),
(133, 'PNY VCQP6000-PB', 'Chipset:Quadro P6000,Memory:24GBCore Clock:1.42GHz', 4059, 5500,
2),
(136, 'AMD Opteron 6378', 'Speed:2.4GHz,Cores:16,TDP:115W', 652, 827, 1),
(142, 'AMD FirePro W9100', 'Chipset:FirePro W9100,Memory:16GBCore Clock:930MHz', 2483, 2999,
2),
(153, 'Intel Xeon E5-2650 V2', 'Speed:2.6GHz,Cores:8,TDP:95W', 961, 1249, 1),
(154, 'Intel Xeon E5-2650 V3', 'Speed:2.3GHz,Cores:10,TDP:105W', 907, 1205, 1),
(155, 'Intel Xeon E5-2630 V2', 'Speed:2.6GHz,Cores:6,TDP:80W', 493, 589, 1),
(158, 'Intel Xeon E5-2667 V3 (OEM/Tray)', 'Speed:3.2GHz,Cores:8,TDP:135W', 1504, 2009, 1),
(159, 'Intel Xeon E5-2690 V4', 'Speed:2.6GHz,Cores:14,TDP:135W', 1499, 1994, 1),
(160, 'Intel Xeon E5-2690 V3', 'Speed:2.6GHz,Cores:12,TDP:135W', 1540, 1909, 1),
(161, 'AMD 100-5056062', 'Chipset:Vega Frontier Edition Liquid,Memory:16GBCore Clock:1.5GHz',
1344, 1500, 2),
(162, 'Intel Xeon E5-2470V2', 'Speed:2.4GHz,Cores:10,TDP:95W', 1672, 1905, 1),
(163, 'Intel Xeon E5-2683 V4', 'Speed:2.1GHz,Cores:16,TDP:120W', 1707, 1900, 1),
(164, 'Intel Xeon E5-2637 V2 (OEM/Tray)', 'Speed:3.5GHz,Cores:4,TDP:130W', 1323, 1850, 1),
(165, 'Intel Xeon E5-2680', 'Speed:2.7GHz,Cores:8,TDP:130W', 1480, 1667, 1),
(166, 'Intel Xeon E5-2680 V3 (OEM/Tray)', 'Speed:2.5GHz,Cores:12,TDP:120W', 1167, 1639, 1),
(167, 'Intel Xeon E5-2650L V3 (OEM/Tray)', 'Speed:1.8GHz,Cores:12,TDP:65W', 779, 1010, 1),
(169, 'Intel Xeon E5-2683 V4 (OEM/Tray)', 'Speed:2.1GHz,Cores:16,TDP:120W', 1370, 1845, 1),
(176, 'Intel Xeon E5-2650 V3 (OEM/Tray)', 'Speed:2.3GHz,Cores:10,TDP:105W', 800, 939, 1),

24
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(177, 'PNY VCQM5000-PB', 'Chipset:Quadro M5000,Memory:8GBCore Clock:861MHz', 1268, 1760,
2),
(178, 'HP C2J95AT', 'Chipset:Quadro K5000,Memory:4GBCore Clock:706MHz', 1716, 2000, 2),
(181, 'ATI FirePro R5000', 'Chipset:FirePro R5000,Memory:2GBCore Clock:825MHz', 761, 1000, 2),
(182, 'PNY VCQK4200-PB', 'Chipset:Quadro K4200,Memory:4GBCore Clock:771MHz', 799, 950, 2),
(183, 'Asus GTX780TI-3GD5', 'Chipset:GeForce GTX 780 Ti,Memory:3GBCore Clock:876MHz', 782,
900, 2),
(184, 'AMD 100-506061', 'Chipset:Vega Frontier Edition,Memory:16GBCore Clock:1.44GHz', 707,
1000, 2),
(185, 'MSI GTX 1080 TI LIGHTNING Z', 'Chipset:GeForce GTX 1080 Ti,Memory:11GBCore
Clock:1.61GHz', 688, 874, 2),
(186, 'PNY VCQK5200-PB', 'Chipset:Quadro K5200,Memory:8GBCore Clock:667MHz', 1129, 1450,
2),
(198, 'Intel Core i7-980', 'Speed:3.33GHz,Cores:6,TDP:130W', 564, 700, 1),
(199, 'Intel Xeon E5-2630 V4', 'Speed:2.2GHz,Cores:10,TDP:85W', 529, 648, 1),
(200, 'Intel Core i7-4790K', 'Speed:4.0GHz,Cores:4,TDP:88W', 462, 621, 1),
(206, 'PNY VCQM6000-24GB-PB', 'Chipset:Quadro M6000,Memory:24GBCore Clock:988MHz', 3619,
4139, 2),
(207, 'PNY VCQM6000-PB', 'Chipset:Quadro M6000,Memory:12GBCore Clock:988MHz', 2505, 3255,
2),
(209, 'Intel Core i7-990X Extreme Edition', 'Speed:3.47GHz,Cores:6,TDP:130W', 1073, 1200, 1),
(210, 'Intel Core i9-7900X', 'Speed:3.3GHz,Cores:10,TDP:140W', 856, 1030, 1),
(211, 'Intel Xeon E5-2650', 'Speed:2.0GHz,Cores:8,TDP:95W', 869, 1065, 1),
(212, 'Intel Xeon E5-2680 V4', 'Speed:2.4GHz,Cores:14,TDP:120W', 1365, 1640, 1),
(213, 'Intel Xeon E5-2643 V3 (OEM/Tray)', 'Speed:3.4GHz,Cores:6,TDP:135W', 1266, 1470, 1), (214,
'Intel Core i7-5960X', 'Speed:3.0GHz,Cores:8,TDP:140W', 866, 1010, 1),
(215, 'PNY VCQP4000-PB', 'Chipset:Quadro P4000,Memory:8GBCore Clock:1.23GHz', 724, 830, 2),
(216, 'MSI GTX 1080 TI LIGHTNING X', 'Chipset:GeForce GTX 1080 Ti,Memory:11GBCore
Clock:1.57GHz', 743, 864, 2),
(218, 'Intel Xeon E5-2660 V4', 'Speed:2.0GHz,Cores:14,TDP:105W', 1194, 1389, 1),
(219, 'Intel Xeon E5-2660 V3', 'Speed:2.6GHz,Cores:10,TDP:105W', 1042, 1300, 1),
(228, 'Intel Xeon E5-2699 V3 (OEM/Tray)', 'Speed:2.3GHz,Cores:18,TDP:145W', 2868, 3410, 1),
(240, 'Intel Core i7-4960X Extreme Edition', 'Speed:3.6GHz,Cores:6,TDP:130W', 1496, 1806, 1),
(241, 'Intel Xeon E5-2699 V4 (OEM/Tray)', 'Speed:2.2GHz,Cores:22,TDP:145W', 1536, 1756, 1),
(242, 'Intel Xeon E5-1680 V3 (OEM/Tray)', 'Speed:3.2GHz,Cores:8,TDP:140W', 1520, 1752, 1),
(243, 'Intel Xeon E5-2643 V4 (OEM/Tray)', 'Speed:3.4GHz,Cores:6,TDP:135W', 1226, 1709, 1),
(245, 'ATI FirePro S9050', 'Chipset:FirePro S9050,Memory:12GBCore Clock:900MHz', 1237, 1699, 2),
25
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
(248, 'Intel Xeon E5-2697 V3', 'Speed:2.6GHz,Cores:14,TDP:145W', 2326, 2775, 1),
(249, 'Intel Xeon E5-2698 V3 (OEM/Tray)', 'Speed:2.3GHz,Cores:16,TDP:135W', 2035, 2661, 1),
(267, 'EVGA 12G-P4-1999-KR', 'Chipset:GeForce GTX Titan
X,Memory:12GBCore Clock:1.15GHz', 1328, 1800, 2),
(281, 'Asus ROG-POSEIDON-GTX1080TI-P11G-GAMING', 'Chipset:GeForce GTX 1080
Ti,Memory:11GBCore Clock:1.62GHz', 696, 865, 2);

CREATE TABLE `product_categories` (


`category_id` int(11) NOT NULL,
`categoryname` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `product_categories` (`category_id`, `categoryname`) VALUES (1,


'CPU'),
(2, 'Video Card'),
(3, 'RAM'),
(4, 'Mother Board'),
(5, 'Storage');

CREATE TABLE `regions` (


`region_id` int(11) NOT NULL,
`regionname` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `regions` (`region_id`, `regionname`) VALUES


(1, 'Europe'),
(2, 'Americas'),
(3, 'Asia'),
(4, 'Middle East and Africa');

CREATE TABLE `warehouses` (


`warehouse_id` int(11) NOT NULL,
`warehousename` varchar(255) DEFAULT NULL,
`location_id` int(11) DEFAULT NULL

26
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `warehouses` (`warehouse_id`, `warehousename`, `location_id`) VALUES


(1, 'Southlake, Texas', 5),
(2, 'San Francisco', 6),
(3, 'New Jersey', 7),
(4, 'Seattle, Washington', 8),
(5, 'Toronto', 9),
(6, 'Sydney', 13),
(7, 'Mexico City', 23),
(8, 'Beijing', 11),
(9, 'Bombay', 12);

ALTER TABLE `contacts`


ADD PRIMARY KEY (`contact_id`);
ALTER TABLE `countries`
ADD PRIMARY KEY (`country_id`),
ADD KEY `regionid` (`region_id`);
ALTER TABLE `customers`
ADD PRIMARY KEY (`customer_id`);

ALTER TABLE `employees`


ADD PRIMARY KEY (`employee_id`);

ALTER TABLE `inventories`


ADD PRIMARY KEY (`product_id`,`warehouse_id`);

ALTER TABLE `locations`


ADD PRIMARY KEY (`location_id`),
ADD KEY `countryid` (`country_id`);

ALTER TABLE `orders`


ADD PRIMARY KEY (`order_id`);

27
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
ALTER TABLE `order_items`
ADD PRIMARY KEY (`order_id`,`item_id`);

ALTER TABLE `products`


ADD PRIMARY KEY (`product_id`),
ADD KEY `categoryid` (`category_id`);

ALTER TABLE `product_categories`


ADD PRIMARY KEY (`category_id`);

ALTER TABLE `regions`


ADD PRIMARY KEY (`region_id`);
ALTER TABLE `warehouses`
ADD PRIMARY KEY (`warehouse_id`),
ADD KEY `locationid` (`location_id`);
ALTER TABLE `contacts`
MODIFY `contact_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=320;

ALTER TABLE `customers`


MODIFY `customer_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=320;

ALTER TABLE `employees`


MODIFY `employee_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=108;

ALTER TABLE `locations`


MODIFY `location_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24;

ALTER TABLE `orders`


MODIFY `order_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=106; ALTER
TABLE `products`
MODIFY `product_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=289;

ALTER TABLE `product_categories`


MODIFY `category_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

28
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

ALTER TABLE `regions`


MODIFY `region_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

ALTER TABLE `warehouses`


MODIFY `warehouse_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;

ALTER TABLE `countries`


ADD CONSTRAINT `countries_ibfk_1` FOREIGN KEY (`region_id`) REFERENCES `regions`
(`region_id`);

ALTER TABLE `locations`


ADD CONSTRAINT `locations_ibfk_1` FOREIGN KEY (`country_id`) REFERENCES `countries`
(`country_id`);

ALTER TABLE `products`


ADD CONSTRAINT `products_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES
`product_categories` (`category_id`);

ALTER TABLE `warehouses`


ADD CONSTRAINT `warehouses_ibfk_1` FOREIGN KEY (`location_id`) REFERENCES
`locations` (`location_id`);
COMMIT;

b) Cloning an existing table


(1) Create table warehouses1 from warehouses without
copying data .

29
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

(2) Create table warehouse1 from warehouses


with data .

(3) Create table employee_m from employee using


select clause having selected number of
columns as employee_id, fullname . fullname
column will be merging of first name and
lastname in columns . Apply constraints to
lastcolumn as NOT NULL .
30
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

(4) Create table employee_m1 from employee


using select clause having selected number of
columns as employee_id , fullname , . fullname
column will be merging of first name and last
name in columns . Apply constraints to
last_column as NOT NOLL . Make
employee_id as primary key .

C)
Alter

Column of Table
(1) Add column “salary” in 0employee_m table
having data type integer and not null .
31
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

(2) Modify column “salary” in employee_m


table by data type float(8,2) and NOT NULL
.

(3) Modify column “salary" to salary_e in


employee_m table having data type int and
NOT NULL .

32
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

(4) Add column date_of_joining in employee_m


table having datatype date and NOT NULL
after fullname.

(5) Drop column “date_of_joining”

33
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

(6) Rename table employee_m to employee_r .

(7) Drop Primary key from table


employee_r.

(8) Remove all data from table


“employee_r” .

34
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

(9) Drop table “employee_r” .

Practical 2 : Manipulating Data with Database


Objects (DML)
1. Clone employee table into employee_i
without data & insert data into employee_i
from employee table .

35
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

2. Display products table with all columns .

36
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
3. select distinct job titles from employee
table.

4. Display city and postal code from


locations table .

37
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

5. Display all details of employees having


last name which contains “ada” substring
.

6. Display all details of employees having


last name which starts with “Jan”.
38
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

7. Display all details of employees having


last name which ends with “na”.

8. Display all details of employees having


last name whose first character is “D” and
third character is “a” and length is 5 letter.

9. Display customer name, credit limit


having remark high or low. If credit limit
is greater than 2500 then mark it as high
else low.

39
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

10. Display first 10 rows from product


table .

11. Display first 4th row from product


table .

40
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

Practical 3 : Retrieving, Restricting and Sorting


Data (DRL)
1. Display all details of employee in hire date order.

2. Display all products in descending order of list


price and category.

41
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

3. Display all countries belongs to Africa, Asia and


America region also arrange them in same order.

4. Display count of employee job title wise .

42
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

5. Display name of products belongs to category 3, 1,


5.
3 P1, P2, P3
1 P7, P9
5 P5, P6

6. List out products with minimum price from each


category.
43
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

Practical 4 : SQL Single Row Functions

1. Write a query to display the current date. Label


the column Date .

2. For each product, display the product number,


name, price, and price increased by 15% and

44
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
expressed as a whole number. Label the
column New Price.

3. Write a query that displays the employee’s


names with the each word capitalized and all
other letters, and the length of the names, for all
employees whose name starts with J, A, or M.
Give each column an appropriate label. Sort the
results by the employees’ last names.

4. List employee name, date of joining , years of


job.

45
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

Practical 5 : SQL Multiple Row Functions


( Aggregate Functions )
1. List products having highest number of products
in specific category .

46
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

2. List product with highest item rate in each


category .

3. List customer having lowest credit limit.

4. List average product price in each category.

47
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

Practical 6 : Displaying Data from Multiple Tables


( Join )
1. List product name with its category name and
arrange them in alphabetically as per category
name .

48
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

2. List customer name, total Items ordered by


customers. Order list by highest number of items
first.

49
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

3. List Name of customers, combined amount of all


orders which has delivered from "New Jersey"
warehouse.

4. List Customer Name, Product Name, Price of


most Expensive Product from each Order,
Arrange most expensive product first.

5. List total number of products sold all warehouses


of India. Display total Product, Warehouse name.
Order warehouses alphabetically.

50
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

Practical 7 : Using Commit and Rollback show


Transaction ACID Property.
• Transaction is a process of executes the instructions
.
• Here we discuss the queries which we do in past and
we will try to understand which queries will be
ready to rollback and which not.
• Firstly we have to chose our database to work on it.
Then fire the query of “start transaction”.

• Here we create one table to check whether the


create query will get rollback or not.

51
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302
• Simple meaning of rollback is just to revert the
operation with the last performed operation.

• As we can see we fire the query for rollback so as


expected output is in total tables we don’t get our
created output in this list. But it’s still there .

• It means create query isn’t get affected by rollback.

• Now we will go towards drop query . Let’s check


drop will affected or not .
• As a result given below drop query also will not be
affected by revert query of rollback.

52
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

• Check for alter query .Alter can’t be affected by


rollback.

• Now move towards the insert query . Insert query


will get rollback , if your transaction get failed and
you want revert the operation .

53
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

• When you get update values then update also be get


rollback.

• Delete query is same as drop set query , drop


statement can’t be revert and delete also not get
revert by rollback as well.

54
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302


We observe that insert statement get rollback, but if
we commit the transaction then insert statement not
get affected by rollback instruction.

• As we see update query get revert , but same


as insert query , if we do it commit then it
stores that result permanently , and it can’t be
revert after commit because it saved that copy
in main database . Revert only work when
you just do changes in temporary copy .

55
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

Practical 8 : Securing data using Views and


Controlling User Access (DCL) .
• We can use view name instead of using table
name it works same as like table name .

56
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302


Use it for fetch the data from the table just replace
the table name with view name. For that use “create
view” keyword.

• We can display all views using table name


and view definition and fetch all the column
names from views which we created .
• We can drop the view as we drop the table.

• Update the view list as do update columns in


tables, Make it in order and can modify in
required way.

57
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

Practical 9 : PL/SQL Block Syntax and DML


Operation through PL/SQL Block .

• PL/SQL blocks have a predefined structure in


which the code is to be grouped . Below are
different sections of PL/SQL blocks.
1. Declaration section
2. Execution section
3. Exception-Handling section
• Name blocks have a specific and unique name for them.

58
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302


Named blocks are basically of two types :
1. Procedure
2. Function Examples
are :

59
12202040501008 Anshita Shah
DATABASE MANAGEMENT SYSTEM - 202040302

60
12202040501008 Anshita Shah
202030402 Akshat Mistry 12202040501006

• Another examples are :


202030402 Akshat Mistry 12202040501006
202030402 Akshat Mistry 12202040501006
202030402 Akshat Mistry 12202040501006

Practical 10 : Control Structures in PL/SQL .


• Here we have some case statements and we
create procedure and do some functioning using
conditional queries .
• For ex.:
delimiter //

• In MySQL, the IF statement is used to execute a block


of SQL statements based on a specified condition. The
basic syntax for the IF statement is as follows:
202030402 Akshat Mistry 12202040501006
• IF condition THEN -- statements to execute when
the condition is true ELSE -- statements to execute
when the condition is false END IF;

• For ex.:

delimiter //

• Case statement :

The CASE statement is used to perform


conditional logic within a query. It can be used
in both the SELECT statement and other
statements like UPDATE or INSERT. Here's a
simple example using the CASE statement in
a SELECT query:
202030402 Akshat Mistry 12202040501006

• While Loop Statement :


• In C language we commonly use this conditional
statement for making finite number of outputs .
Here we put query statement with using some
specific words.
202030402 Akshat Mistry 12202040501006

• Here we try another example :

• Leave Statement :
• Leave statement work as continue statement ,
mostly use for terminate the condition by putting
specific condition .
202030402 Akshat Mistry 12202040501006

Queries :
DELIMITER //

CREATE PROCEDURE leave_procedure()


BEGIN
DECLARE counter INT DEFAULT 1; simple_loop:
LOOP
IF counter = 3 THEN
SET counter = counter + 1;
ITERATE simple_loop;
END IF;
SELECT counter;
SET counter = counter + 1;
-- Exit the loop when counter exceeds 5
IF counter > 5 THEN
LEAVE simple_loop;
END IF;
END LOOP;
END // DELIMITER
;
202030402 Akshat Mistry 12202040501006

• Iterate statement ex.:


202030402 Akshat Mistry 12202040501006

Practical 11 : Working with Cursor


A cursor allows you to iterate a set of rows returned by a query and process each row
individually.

MySQL cursor is read-only, non-scrollable and a sensitive.

• Read-only: you cannot update data in the underlying table through the cursor.
• Non-scrollable: you can only fetch rows in the order determined by the SELECT
statement. You cannot fetch rows in the reversed order. In addition, you cannot skip
rows or jump to a specific row in the result set.
• Asensitive: there are two kinds of cursors: a sensitive cursor and insensitive cursor.
An asensitive cursor points to the actual data, whereas an insensitive cursor uses a
temporary copy of the data. A sensitive cursor performs faster than an insensitive
cursor because it does not have to make a temporary copy of data. However, any
change that is made to the data from other connections will affect the data that is being
used by a sensitive cursor, therefore, it is safer if you do not update the data that is
being used by an a sensitive cursor. MySQL cursor is asensitive.

Working with MySQL cursor

First, declare a cursor by using the DECLARE statement:

DECLARE cursor_name CURSOR FOR SELECT_statement;

The cursor declaration must be after any variable declaration. If you declare a cursor before
the variable declarations, MySQL will issue an error. A cursor must always be associated
with a SELECT statement.

Next, open the cursor by using the OPEN statement. The OPEN statement initializes the
result set for the cursor, therefore, you must call the OPEN statement before fetching rows
from the result set.

OPEN cursor_name;

Then, use the FETCH statement to retrieve the next row pointed by the cursor and move the
cursor to the next row in the result set.

FETCH cursor_name INTO variables list;


202030402 Akshat Mistry 12202040501006

After that, check if there is any row available before fetching it.

Finally, deactivate the cursor and release the memory associated with it using the CLOSE
statement:

CLOSE cursor_name;

When working with MySQL cursor, you must also declare a NOT FOUND handler to handle
the situation when the cursor could not find any row.

Because each time you call the FETCH statement, the cursor attempts to read the next row in
the result set. When the cursor reaches the end of the result set, it will not be able to get the
data, and a condition is raised. The handler is used to handle this condition.

To declare a NOT FOUND handler, you use the following syntax:

DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished = 1;

The finished is a variable to indicate that the cursor has reached the end of the result set.
Notice that the handler declaration must appear after variable and cursor declaration inside
the stored procedures.

The following diagram illustrates how MySQL cursor works.

Example :
202030402 Akshat Mistry 12202040501006

Example 2:
202030402 Akshat Mistry 12202040501006

• Types of Cursors:
202030402 Akshat Mistry 12202040501006
Non-Scrollable (Forward-Only) Cursor:
This type of cursor allows you to traverse the result set
only in the forward direction, from the first to the last
row.
It does not support backward movement or random access to
rows .

We are take one example to understand the concept .


202030402 Akshat Mistry 12202040501006

• Another example :

Scrollable Cursor:

• This type of cursor allows you to traverse the result set


in both forward and backward directions. It also allows
random access to rows.
202030402 Akshat Mistry 12202040501006

• Scrollable cursors provide more flexibility but may


have a performance cost.

Example :
202030402 Akshat Mistry 12202040501006

Example 2:
202030402 Akshat Mistry 12202040501006

Practical 12 : Creating Procedures and


Functions in PL/SQL
• PL/SQL blocks have a predefined structure in
which the code is to be grouped . Below are
different sections of PL/SQL blocks.
4. Declaration section
5. Execution section
6. Exception-Handling section
• Name blocks have a specific and unique name for
them.
• Named blocks are basically of two types :
3. Procedure
4. Function Examples are :
202030402 Akshat Mistry 12202040501006
202030402 Akshat Mistry 12202040501006

• Another examples are :


202030402 Akshat Mistry 12202040501006
202030402 Akshat Mistry 12202040501006

Practical 13 : Creating Database


Triggers
Example :

• If you drop a table, any triggers for the table are


also dropped. By using this query :
DROP TRIGGER test.ins_sum; •
creation of trigger:

• syntax for creating procedure :


202030402 Akshat Mistry 12202040501006

• Triggers can contain direct references to tables by


name, such as the trigger named testref shown in
this example:
202030402 Akshat Mistry 12202040501006

• Result will look like this :


Same result for test 2

You might also like