First we create the database by using command:-
mysql> create database manufacturing;
Query OK, 1 row affected (0.00 sec)
mysql> use manufacturing;
Database changed.
Now we create the tables product,manufacturer and stock respectively as follows:-
mysql> create table product(productID int(3)not null,productName varchar(20),productDescription varchar(50), manufacturerID int(1), primary key (productID));
mysql> create table manufacturer(manufacturerName varchar(20)not null,manufacturerID varchar(1), primary key (manufacturerID));
mysql> create table stock(productID int(3)not null,quantity int(5),foreign key (productID) references product (productID));
Now we insert the records in each tables as follows:-
mysql> insert into product values(101,'keyboard','economic keyboard with rest pad',1);
mysql> insert into product values(102,'printer','HP model 3456',1);
mysql> insert into product values(103,'lpad version 2.5','5*7 inch monitor with stylus',2);
mysql> insert into manufacturer values('Dell',1);
mysql> insert into manufacturer values('Apple',2);
mysql> insert into stock values(101,100);
mysql> insert into stock values(102,400);
mysql> insert into stock values(103,300);
Now we display the tables with the records as follows:-
mysql> select * from product;
+-------------+---------------------+---------------------------------------------+---------------------+
| productID | productName | productDescription | manufacturerID
|
+-------------+---------------------+---------------------------------------------+---------------------+
| 101 | keyboard | economic keyboard with rest pad | 1
|
| 102 | printer | HP model 3456 | 1 |t
| 103 | lpad version 2.5 | 5*7 inch monitor with stylus | 2 |
+-------------+---------------------+---------------------------------------------+---------------------+
mysql> select * from manufacturer;
+--------------------------+---------------------+
| manufacturerName | manufacturerID |
+--------------------------+---------------------+
| Dell | 1 |
| Apple | 2 |
+--------------------------+----------------------+
mysql> select * from stock;
+-------------+------------+
| productID | quantity |
+-------------+------------+
| 101 | 100 |
| 102 | 400 |
| 103 | 300 |
+-------------+------------+
Now we insert the new records(2 tuples) in each tables as follows:-
mysql> insert into product values(509,'Apple Watch','Serious 5 pink',2);
mysql> insert into product values(876,'Macbook pro','32G memory 8 core intel processor',2);
mysql> insert into manufacturer values ('Acer',3);
mysql> insert into manufacturer values ('Toshiba',4);
mysql> insert into stock values (509,500);
mysql> insert into stock values (876,600);
Now we update the tables according to the question as follows:-
mysql> update product set productDescription="Dell model
6543" where productID=102;
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update stock set quantity=400 where
productID=102;
Rows matched: 1 Changed: 0 Warnings: 0
Now the new tables after adding new records and updating the existing records will become as follows:-
mysql> select * from product;
+-------------+---------------------+------------------------------------------------+---------------------+
| productID | productName | productDescription | manufacturerID
|
+-------------+---------------------+------------------------------------------------+---------------------+
| 101 | keyboard | economic keyboard with rest pad | 1 |
| 102 | printer | Dell model 6543 | 1 |
| 103 | lpad version 2.5 | 5*7 inch monitor with stylus | 2 |
| 509 | Apple Watch | Serious 5 pink | 2 |
| 876 | Macbook pro | 32G memory 8 core intel processor | 2 |
+-------------+----------------------+------------------------------------------------+--------------------+
mysql> select * from manufacturer;
+--------------------------+---------------------+
| manufacturerName | manufacturerID |
+--------------------------+----------------------+
| Dell | 1 |
| Apple | 2 |
| Acer | 3 |
| Toshiba | 4 |
+---------------------------+---------------------+
mysql> select * from stock;
+-------------+-----------+
| productID | quantity|
+-------------+-----------+
| 101 | 100 |
| 102 | 400 |
| 103 | 300 |
| 509 | 500 |
| 876 | 600 |
+-------------+------------+
The screensot of all the steps in mysql in ubantu operating system ase as follows:-
These are the complete photos of all the steps shown in the pictures.
Insert the bottom two rows to each table we made in class and update the two...
Homework Assignment #9: Selects On assignment #8 that we started in class and you finished on your own, you created three tables Product Manufacturer and Stock For this assignment you will be working with these same tables Please complete the following tasks and submit in word file or notepad. 1. First insert tuples into two of the tables Write and execute the SQL to insert three records ProductID 844,555 and 645 to the Product table (see below) Write and execute...