64 648
Assignments Done
99,2%
Successfully Done
In September 2018

Answer to Question #51278 in Databases | SQL | Oracle | MS Access for Zexy

Question #51278
Use SQL commands to create the tables and attributes. Make sure that you assign the appropriate datatypes such as NUM, CHAR, etc.
Expert's answer
Answer:
CREATE TABLE inventory
(
   id INTIDENTITY(1,1) PRIMARY KEY,
   productVARCHAR(50) UNIQUE,
   quantity INT,
   priceDECIMAL(18,2)
);
CREATE TABLE inventory - this line informs SQL of theplan to create a new table using the CREATE clause andspecifies the name of the new table (inventory).
id INT IDENTITY(1,1) PRIMARYKEY - line 2 should appear moreforeign as there is a lot of information embedded in this line, but it is not
as hard as it seems. This is the first line that declares how to set up the
first table column inside the new inventory table.
id = Thename of this new table column.
INT = Thedata type. INT is short for integer.
The first word, id, is the name of thisnew column and the second word declares the data type, INT (integers). SQL will
now expect this table column to house only integer data type values.
IDENTITY (1,1) = The id column will be an identity column.
PRIMARY KEY = This places a restraint on this column (no duplicate values)
product VARCHAR(50) UNIQUE,line  specifiesthe name and type of the second column in the inventory table. Product stands
for the inventory table product name and this column is set as a VARCHAR(50),which means it will be able to handle numbers, letters, and special characters
as values. In other words, "Any words, numbers, or special characters can
be placed into this column value, with a 50 character limit."
   quantity INT,    price DECIMAL(18,2) - these lines are creating two more table columns: quantity and price.Since the price column will be dealing with decimals, we have set this column
to a DECIMAL data type to handle decimals (sometimes called floating point
numbers).
And there you have it, here's another look at thequery:
Let's go ahead and add some records into this table sothat we can then use this table
SQL Insert Into:
INSERT INTO inventory
VALUES('19" LCD Screen','25','179.99');
INSERT INTO inventory
VALUES('HPPrinter','9','89.99');
INSERT INTO inventory
VALUES('Pen','78','0.99');
In creating this new table with data that relates todata inside the orders table, you have created a relationaldatabase. 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions