implemented spec for confectionery#49
Conversation
AvigailGellis
left a comment
There was a problem hiding this comment.
Amazing job! See comments, fix and resubmit.
| (Topping in ('royal icing', 'fondant', 'chocolate', 'caramel', 'strawberry', 'coconut', 'peanut butter', 'no topping')) , | ||
| CustomSpecification varchar (350) not null | ||
| default '', | ||
| Photo varchar (3) not null |
There was a problem hiding this comment.
Photo should be a bit column
| Occasion varchar (50) not null | ||
| default '', | ||
|
|
||
| constraint c_confectionery_when_product_type_is_cookie_base_must_be_sugar check ((ProductType = 'cookie' and BaseType ='sugar') or (ProductType in ('cake', 'cupcake'))), |
There was a problem hiding this comment.
It doesn't say anywhere that cookies must be sugar. I see the sample data only includes sugar cookies but that doesn't mean there is no option for other bases.
There was a problem hiding this comment.
I removed this constraint.
| default '', | ||
|
|
||
| constraint c_confectionery_when_product_type_is_cookie_base_must_be_sugar check ((ProductType = 'cookie' and BaseType ='sugar') or (ProductType in ('cake', 'cupcake'))), | ||
| constraint c_confectionery_amount_must_be_between_twelve_and_five_hundred_when_the_product_type_is_cupcake check ((ProductType = 'cupcake' and Amount between 12 and 500) |
There was a problem hiding this comment.
The constraint message only includes the first part of the constraint.
There was a problem hiding this comment.
I completed the constraint message.
| Photo varchar (3) not null | ||
| constraint c_confectionery_photo_must_be_either_yes_or_no check (Photo in ('yes', 'no')), | ||
| Amount int not null, | ||
| CostPerItem decimal (4,2) not null, |
There was a problem hiding this comment.
Since the instructions of what each item should cost (based off of product type and picture) is written out fully in the spec, this column should be a computed column. This should replace the constraints you have below about the pricing.
There was a problem hiding this comment.
okay, I created a computed column for the total cost.
| Amount int not null, | ||
| CostPerItem decimal (4,2) not null, | ||
| TotalCost decimal (6,2) not null, | ||
| Occasion varchar (50) not null |
There was a problem hiding this comment.
Occasion should not allow blanks
There was a problem hiding this comment.
okay, it does not allow blanks now.
| constraint c_confectionery_photo_must_be_either_yes_or_no check (Photo in ('yes', 'no')), | ||
| Amount int not null, | ||
| CostPerItem decimal (4,2) not null, | ||
| TotalCost decimal (6,2) not null, |
There was a problem hiding this comment.
Total cost should also be a computed column. However, since you can't make a computed column off of another computed column, you will have the same calculation you make for CostPerItem and then just multiply it by the amount.
There was a problem hiding this comment.
okay, thanks for the tip!
| delete confectionery | ||
| go | ||
|
|
||
| insert Confectionery (CustomerFirstName, CustomerLastName, Branch, OrderDate, BaseType, ProductType, Topping, Photo, CustomSpecification, Occasion, Amount, CostPerItem, TotalCost) |
There was a problem hiding this comment.
Please put in all the sample data provided.
There was a problem hiding this comment.
I inserted all the sample data.
| @@ -0,0 +1,42 @@ | |||
| --1) | |||
There was a problem hiding this comment.
Insert alias's in all your questions.
| drop table if exists Confectionery | ||
| go | ||
|
|
||
| create table dbo.Confectionery( |
There was a problem hiding this comment.
A clearer name for such a table would be Orders.
There was a problem hiding this comment.
I changed the table name to orders
No description provided.