Mall Database Relations Employees( eid: integer, name: String, position: String,
ID: 3704045 • Letter: M
Question
Mall Database Relations Employees( eid: integer, name: String, position: String, salary: double ): 15] Employs( store: String, eid: integer): [201 Stores(name: String, location: String ): [4] ltems( item: String, brand: String, price: double : 15] Inventory( name: String, item: String, quantity: integer ): [25] Customers(name: String, address: String, aid: integer ): [5] Transactions( tid: integer, store: String, item: String, customer: String, date: Date ): [30] balance: double, type: String ): 7; type must be one of credit, checking, or cash ] Exercises [15 pts] Modify the database Mall to use the relations given here. Note, these relations are based upon the solution to Hw #7, but they are slightly different. 1. [10 pts] Populate each table in the database with at least the number of tuples (record entries) given in the brackets following each relation. 2.Explanation / Answer
Here I am giving you MySql dump which i created as per avove and inserted sample data.
You can just import this dump file into Workbench and insert data as you wanted.
Please copy this as whole into file and save it as .sql extenstion. Use this file to import into workbench.
CREATE DATABASE IF NOT EXISTS `mall` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `mall`;
-- MySQL dump 10.13 Distrib 5.7.17, for Win64 (x86_64)
--
-- Host: localhost Database: mall
-- ------------------------------------------------------
-- Server version 5.6.38-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `accounts`
--
DROP TABLE IF EXISTS `accounts`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `accounts` (
`aid` int(11) NOT NULL,
`balance` double DEFAULT NULL,
`type` varchar(45) DEFAULT NULL,
PRIMARY KEY (`aid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `accounts`
--
LOCK TABLES `accounts` WRITE;
/*!40000 ALTER TABLE `accounts` DISABLE KEYS */;
INSERT INTO `accounts` VALUES (1,6500,'cash'),(2,4000,'checking'),(3,3000,'credit');
/*!40000 ALTER TABLE `accounts` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `customers`
--
DROP TABLE IF EXISTS `customers`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `customers` (
`name` varchar(80) DEFAULT NULL,
`address` varchar(45) DEFAULT NULL,
`aid` int(11) DEFAULT NULL,
KEY `aid_fk_idx` (`aid`),
CONSTRAINT `aid_fk` FOREIGN KEY (`aid`) REFERENCES `accounts` (`aid`) ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `customers`
--
LOCK TABLES `customers` WRITE;
/*!40000 ALTER TABLE `customers` DISABLE KEYS */;
INSERT INTO `customers` VALUES ('John','CA',1),('Smith','TX',2),('Alex John','CA',3);
/*!40000 ALTER TABLE `customers` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `employees`
--
DROP TABLE IF EXISTS `employees`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `employees` (
`eid` int(11) NOT NULL,
`name` varchar(80) DEFAULT NULL,
`position` varchar(45) DEFAULT NULL,
`salry` double DEFAULT NULL,
PRIMARY KEY (`eid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `employees`
--
LOCK TABLES `employees` WRITE;
/*!40000 ALTER TABLE `employees` DISABLE KEYS */;
INSERT INTO `employees` VALUES (1,'Steve','Manager',6000),(2,'Smith','clerk',4500),(3,'Bob','clrek',4000),(4,'Bobby','Assisttent',3000),(5,'Bobby Sri','Assisttent',4000),(6,'Gangburg','Keeper',5000);
/*!40000 ALTER TABLE `employees` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `employs`
--
DROP TABLE IF EXISTS `employs`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `employs` (
`store` varchar(80) NOT NULL,
`eid` int(11) NOT NULL,
PRIMARY KEY (`store`,`eid`),
KEY `eid_fk_idx` (`eid`),
CONSTRAINT `eid_fk` FOREIGN KEY (`eid`) REFERENCES `employees` (`eid`) ON UPDATE NO ACTION,
CONSTRAINT `sotre_fk` FOREIGN KEY (`store`) REFERENCES `stores` (`name`) ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `employs`
--
LOCK TABLES `employs` WRITE;
/*!40000 ALTER TABLE `employs` DISABLE KEYS */;
INSERT INTO `employs` VALUES ('CA Store',1),('TX Store',5);
/*!40000 ALTER TABLE `employs` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `inventory`
--
DROP TABLE IF EXISTS `inventory`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `inventory` (
`name` varchar(80) NOT NULL,
`item` varchar(45) DEFAULT NULL,
`quantity` int(11) DEFAULT NULL,
PRIMARY KEY (`name`),
KEY `items_fk_idx` (`item`),
CONSTRAINT `items_fk` FOREIGN KEY (`item`) REFERENCES `items` (`item`) ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `inventory`
--
LOCK TABLES `inventory` WRITE;
/*!40000 ALTER TABLE `inventory` DISABLE KEYS */;
INSERT INTO `inventory` VALUES ('one','soap',10),('two','brush',15);
/*!40000 ALTER TABLE `inventory` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `items`
--
DROP TABLE IF EXISTS `items`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `items` (
`item` varchar(80) NOT NULL,
`brand` varchar(80) DEFAULT NULL,
`price` double DEFAULT NULL,
PRIMARY KEY (`item`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `items`
--
LOCK TABLES `items` WRITE;
/*!40000 ALTER TABLE `items` DISABLE KEYS */;
INSERT INTO `items` VALUES ('Brush','Oral-B',2),('paste','Vivvo',5),('soap','Lux',2);
/*!40000 ALTER TABLE `items` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `stores`
--
DROP TABLE IF EXISTS `stores`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `stores` (
`name` varchar(80) NOT NULL,
`location` varchar(80) DEFAULT NULL,
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `stores`
--
LOCK TABLES `stores` WRITE;
/*!40000 ALTER TABLE `stores` DISABLE KEYS */;
INSERT INTO `stores` VALUES ('CA Store','CA'),('TX Store','TX');
/*!40000 ALTER TABLE `stores` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tranasactions`
--
DROP TABLE IF EXISTS `tranasactions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tranasactions` (
`tid` int(11) NOT NULL,
`store` varchar(80) DEFAULT NULL,
`item` varchar(80) DEFAULT NULL,
`customer` varchar(80) DEFAULT NULL,
`date` date DEFAULT NULL,
PRIMARY KEY (`tid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tranasactions`
--
LOCK TABLES `tranasactions` WRITE;
/*!40000 ALTER TABLE `tranasactions` DISABLE KEYS */;
INSERT INTO `tranasactions` VALUES (1,'CA Store','paste','Smith','2018-04-10'),(2,'TX Store','brush','Alex Smith','2018-04-10');
/*!40000 ALTER TABLE `tranasactions` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2018-04-10 9:13:39
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.