Skip to content

implemented Bike-shop bussiness scenario#55

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

implemented Bike-shop bussiness scenario#55
AvrumiG wants to merge 2 commits into
CPU-Code-School:mainfrom
AvrumiG:main

Conversation

@AvrumiG
Copy link
Copy Markdown

@AvrumiG AvrumiG commented Dec 29, 2024

Pull request for Bike-shop Biz-scenario

Comment thread 1 table.sql Outdated
BikeCompany varchar(100) not null constraint ck_Bike_Company_cannot_be_blank check(BikeCompany <> ''),
BikeSize varchar(6) not null constraint ck_Bike_Size_cannot_be_blank check(BikeSize <> ''),
BikeColor varchar(15) not null constraint ck_Bike_Color_cannot_be_blank check(BikeColor <> ''),
DatePurchased date not null constraint ck_Date_Purchased_must_be_after_1st_of_march_2022 check(DatePurchased > '2022-03-01'),
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.

Make sure that DatePurchased is not in the future. This condition can be combined with the constraint below.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

Comment thread 1 table.sql Outdated
BikeSize varchar(6) not null constraint ck_Bike_Size_cannot_be_blank check(BikeSize <> ''),
BikeColor varchar(15) not null constraint ck_Bike_Color_cannot_be_blank check(BikeColor <> ''),
DatePurchased date not null constraint ck_Date_Purchased_must_be_after_1st_of_march_2022 check(DatePurchased > '2022-03-01'),
PurchasePrice decimal(6,2) 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.

Make sure that PurchasePrice is greater than 0.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

Comment thread 1 table.sql Outdated
BikeColor varchar(15) not null constraint ck_Bike_Color_cannot_be_blank check(BikeColor <> ''),
DatePurchased date not null constraint ck_Date_Purchased_must_be_after_1st_of_march_2022 check(DatePurchased > '2022-03-01'),
PurchasePrice decimal(6,2) not null,
New varchar (12) constraint ck_New_column_must_be_either_New_or_Used check(New in('new','Used')),
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.

A better practice would be to use a bit datatype for the column 'New'.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done

Comment thread 1 table.sql Outdated
DatePurchased date not null constraint ck_Date_Purchased_must_be_after_1st_of_march_2022 check(DatePurchased > '2022-03-01'),
PurchasePrice decimal(6,2) not null,
New varchar (12) constraint ck_New_column_must_be_either_New_or_Used check(New in('new','Used')),
ConditionReceived varchar (11),
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.

An improvement would be to record the condition as an INT column with a computed column for descriptions.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

Comment thread 1 table.sql Outdated
PurchasePrice decimal(6,2) not null,
New varchar (12) constraint ck_New_column_must_be_either_New_or_Used check(New in('new','Used')),
ConditionReceived varchar (11),
dateSold date,
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.

  1. Change date Sold to proper case (DateSold instead of dateSold).
  2. Make sure that DateSold is not in the future.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

Comment thread 1 table.sql Outdated
New varchar (12) constraint ck_New_column_must_be_either_New_or_Used check(New in('new','Used')),
ConditionReceived varchar (11),
dateSold date,
season varchar(10) not null constraint ck_season_cannot_be_blank check(season <> ''),
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.

Season should be a computed column based on the date sold.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

Comment thread 1 table.sql Outdated
ConditionReceived varchar (11),
dateSold date,
season varchar(10) not null constraint ck_season_cannot_be_blank check(season <> ''),
SalePrice decimal(6,2) constraint ck_Sale_price_cannot_be_more_then_3000 check(SalePrice <3001),
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.

Make sure that SalePrice is greater than 0. This condition can be combined with the constraint below.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

Comment thread 1 table.sql
CONSTRAINT ck_Condition_Received_for_a_used_bike_must_be_either_In_Perfect_or_Minor_fixup_or_Major_fixup_or_Restoration
CHECK (new <> 'used' or ConditionReceived in('Perfect', 'Minor Fixup', 'Major Fixup', 'Restoration')),
constraint ck_Date_sold_must_be_after_date_purchased check(dateSold > DatePurchased)
)
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.

Ensure that for a new bike, the ConditionReceived column is null, and for a used bike the column has a value.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Working with nulls is causing an error when it comes to combine varchar velues in the Desc column, I did it a different way, please let me know if it's ok.

Comment thread 3 queries.sql
go

--1) I would like to know how many local customers I have as oppose to out-of-town customers.
select
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.

Make sure that the result excludes null addresses.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed (just to clarify, the spec didn't mention that non sold bikes are included in the data)

Comment thread 3 queries.sql
count(case when b.CustomerAddress not like '%Spring Valley%' then 1 end) as OutOfTownCustomers
from bike b

--2) The amount of bikes sold per season to know what is my busiest season.
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 might want to add a filter to include only bikes that were sold.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed (again the spec sounds like we talk about sold bikes only)

Comment thread 3 queries.sql
order by AmountSold desc

--3) I need a report with the average, minimum and maximum amount of time a bike was in my store before I sold it. Also show in this report my total profit so far.
select
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.

Make sure to include only bikes that were sold.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

Comment thread 3 queries.sql
from bike b

--4) I need a report with the profit for each sale and show the Customers name, BikeCompany, PurchasePrice, SoldPrice, New/Used.
select b.CustomerName, b.BikeCompany, b.PurchasePrice, b.SalePrice, b.New, b.SalePrice - b.PurchasePrice as Profit
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, make sure to include only bikes that were sold.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Copy Markdown
Contributor

@LeahBineth LeahBineth left a comment

Choose a reason for hiding this comment

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

Great job!! Please see comments above and resubmit.

Copy link
Copy Markdown
Contributor

@LeahBineth LeahBineth left a comment

Choose a reason for hiding this comment

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

...

@AvrumiG
Copy link
Copy Markdown
Author

AvrumiG commented Jan 5, 2025

Please take a look at my latest commit and let me know if everything is resolved.

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.

2 participants