For this question I keep getting an error when I’m trying to create the table. I
ID: 3748098 • Letter: F
Question
For this question I keep getting an error when I’m trying to create the table. I think I am making a mistake with the base price float. What would be correct? Thank you. Create table staff( stall_id int NOT NULL AUTO_INCREMENT, stall_number ENUM(‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘10’), base_price float NOT NULL DECIMAL(5,2), primary key(stall_id)11. Create a table in database horsestable called stall with the following attributes, data types, and constraints: a. stall id, integer, not null, auto increment stall number, enumeration with values of 1,2,3,4,5,6,7,8,9,10 c. base price, floating point, not null, 5 digits, 2 d. primary key is the stall id field digits to the right of the decimal point
Explanation / Answer
The error is basically because you are specifying two data types on the single attribute base_price as in:
base_price float NOT NULL DECIMAL(5,2),
You are using float as well as decimal for this column. Also, the decimal data type has been specified after the Not Null constraint which is a syntactical error. The correct query looks like this:
Create table staff(
stall_id int NOT NULL AUTO_INCREMENT,
stall_number ENUM('1', '2', '3', '4', '5', '6', '7', '8', '9', '10'),
base_price DECIMAL(5,2) NOT NULL,
primary key(stall_id)
);
The query now runs without any error and is tested.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.