Skip to content

Costume#45

Open
bassie1 wants to merge 2 commits into
CPU-Code-School:mainfrom
bassie1:main
Open

Costume#45
bassie1 wants to merge 2 commits into
CPU-Code-School:mainfrom
bassie1:main

Conversation

@bassie1
Copy link
Copy Markdown

@bassie1 bassie1 commented Mar 6, 2024

No description provided.

@astrohlicpu astrohlicpu self-assigned this Nov 27, 2024
@astrohlicpu astrohlicpu self-requested a review November 27, 2024 23:33
Copy link
Copy Markdown
Contributor

@astrohlicpu astrohlicpu left a comment

Choose a reason for hiding this comment

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

Nice job! Please see my comments

Comment thread 2 table costume.sql
CustomerLastName varchar(25) not null,
constraint c_Costume_customer_last_name_cannot_be_blank check(CustomerLastName > ''),
CostumesBought varchar(100) not null,
constraint c_Costume_costumes_bought_must_be_one_of_the_costume_choices
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So far they are only selling those costumes, but since this may change we wouldn't constrain it.

Comment thread 2 table costume.sql
constraint c_Costume_costumes_bought_must_be_one_of_the_costume_choices
check(CostumesBought in ('American Girl Doll', 'Artist', 'Bumble Bee', 'Colonial Boy', 'Colonial Girl', 'Elephant', 'Fire Man', 'Police Man', 'Princess', 'Zebra')),
CostumeSize varchar(2) not null,
constraint c_Costume_costume_size_cannot_be_blank check(CostumeSize > ''),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here the spec says that there are only 5 options. You can therefor safely make a constraint to only these 5 options.

Comment thread 2 table costume.sql
constraint c_Costume_costume_size_cannot_be_blank check(CostumeSize > ''),
CostumeAmount int not null,
constraint c_Costume_costume_amount_must_be_greater_than_zero check (CostumeAmount > 0),
CostumeCostPrice int not null,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since the price is dependent on the size, you can compute it of the size.

Comment thread 2 table costume.sql
TotalPrice as CostumeSoldPrice * CostumeAmount persisted,
constraint c_Costume_sold_price_must_be_more_than_or_equal_to_cost_price check(CostumeSoldPrice >= CostumeCostPrice),
constraint c_Costume_date_sold_must_be_on_or_after_date_bought check(DateSold >= DateBought),
constraint c_Costume_total_price_must_be_greater_than_or_equal_to_sold_price check(TotalPrice >= CostumeSoldPrice)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since the total price is a computed column, there is no need for this constraint.

Comment thread 4 reports.sql
go

--1. I need to know which costume is the most popular.
select top 1 AmountPerCostume = count (*), c.CostumesBought
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can have a costume which is only in one row in the table, but was the AmountBought can be 12, which would make it the most popular column

Comment thread 4 reports.sql
group by c.CostumesBought
order by AmountPerCostume desc

--2. I need to know which size is the most polpular.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same issue as previous report

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.

3 participants