Skip to content

I did the work#37

Open
RassiLevine wants to merge 7 commits into
CPU-Code-School:mainfrom
RassiLevine:main
Open

I did the work#37
RassiLevine wants to merge 7 commits into
CPU-Code-School:mainfrom
RassiLevine:main

Conversation

@RassiLevine
Copy link
Copy Markdown

confectionary

Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! See comments, fix and resubmit.

Comment thread 1 table.sql Outdated

create table dbo.confectionary(
confectionaryID int not null identity primary key,
FullName varchar(30) not null,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't allow blank.

Comment thread 1 table.sql Outdated
constraint ck_confectionary_branch_can_only_be_lakewood_or_brooklyn check(branch in ('Lakewood', 'Brooklyn')),
DateOrdered date not null
constraint ck_confectionary_DateOrdered_cant_be_before_january_1_2021 check(DateOrdered >= '01/01/2021'),
TypeOfBase varchar(25) not null,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should only be specified types.

Comment thread 1 table.sql Outdated
TypeOfBase varchar(25) not null,
Item varchar(8) not null
constraint ck_confectionary_item_can_only_be_cake_cupcake_or_cookie check (item in ('cake', 'cupcake', 'cookie')),
Topping varchar(15) not null,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can only be specified values.

Comment thread 1 table.sql Outdated
Item varchar(8) not null
constraint ck_confectionary_item_can_only_be_cake_cupcake_or_cookie check (item in ('cake', 'cupcake', 'cookie')),
Topping varchar(15) not null,
Picture varchar(3) not null
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can only be 2 values. Use bit column.

Comment thread 1 table.sql Outdated
Picture varchar(3) not null
constraint ck_confectionary_picture_must_eitehr_be_yes_or_no check(picture in ('yes', 'no')),
Specifics varchar(100) null,
Occasion varchar(35) not null,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't allow blank.

Comment thread 1 table.sql
Specifics varchar(100) null,
Occasion varchar(35) not null,
Amount int not null
constraint ck_confectionary_amount_cannot_be_more_than_Five_hundred check(amount <= 500),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't allow negative.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing 2 check constraints. Combine them together using between or and.

Comment thread 1 table.sql Outdated
constraint ck_confectionary_amount_cannot_be_more_than_Five_hundred check(amount <= 500),
PricePerItem as
case
when item = 'Cookie' then 3.50
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to include in logic the price for those with pictures. That would be price per item.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way you did it now won't work because the line when item = 'Cookie' then 3.50 is executed first so it will return 3.50 whether it has a picture or not.

Comment thread 1 table.sql Outdated
when item = 'cupcake' then 3.00
end,

PriceOfOrder as
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can use same case statement as PricePerItem. Just add * amount after doing the case.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After end of case do * amount to make all cases * amount.

Comment thread 2.data.sql
@@ -0,0 +1,29 @@
use ConfectionaryDB
go

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add delete.

@RassiLevine
Copy link
Copy Markdown
Author

I made the changes.

Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent improvements! See comments, fix and resubmit.

Comment thread 1 table.sql Outdated
constraint ck_confectionary_item_can_only_be_cake_cupcake_or_cookie check (item in ('cake', 'cupcake', 'cookie')),
Topping varchar(15) not null
constraint c_must_be_specific_topping check(Topping in ('Fondant', 'Frosting', 'Royal icing', 'chocolate peanut butter', 'vanilla', 'chocolate', 'caramel', 'strawberry', 'coconut', 'peanut butter', 'none')),
Picture bit,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't allow null.

Comment thread 1 table.sql Outdated
constraint ck_confectionary_amount_cannot_be_more_than_Five_hundred check(amount <= 500),
PricePerItem as
case
when item = 'Cookie' then 3.50
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way you did it now won't work because the line when item = 'Cookie' then 3.50 is executed first so it will return 3.50 whether it has a picture or not.

Comment thread 1 table.sql Outdated
when item = 'cupcake' then 3.00
end,

PriceOfOrder as
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After end of case do * amount to make all cases * amount.

Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! 100% See comments, no need to resubmit.

Comment thread 1 table.sql
Specifics varchar(100) null,
Occasion varchar(35) not null,
Amount int not null
constraint ck_confectionary_amount_cannot_be_more_than_Five_hundred check(amount <= 500),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing 2 check constraints. Combine them together using between or and.

Comment thread 1 table.sql
when picture =1 and item = 'cookie' then 3.50 +1.50*amount
when picture = 1 and item = 'cake' and typeOfBase = 'Strawberry Shortcake' then 55.00+8.00*amount
when picture = 1 and item = 'cake' and typeOfBase <> 'Strawberry Shortcake' then 50.00+8.00*amount
end * amount,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're doing * amount here, you should remove it from inside the case statement. I just recommended to do it here instead of doing it multiple times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant