Skip to content

implemented army biz scenario#27

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

implemented army biz scenario#27
estigoldberger wants to merge 2 commits into
CPU-Code-School:mainfrom
estigoldberger:main

Conversation

@estigoldberger
Copy link
Copy Markdown

I implemented the Army Biz-Scenario.

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! Some changes needed. See comments on PR, fix and resubmit.

Comment thread 1. table.sql
SoldierID int not null identity primary key,
FirstName varchar (30) not null constraint first_name_cannot_be_blank check (FirstName <> ''),
LastName varchar (30) not null constraint last_name_cannot_be_blank check (LastName <> ''),
SSN char (10) not null constraint ck_ssn_10_characters check (len (SSN) = 10)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

len(SSN) is not enough when using char(10), as this adds extra spaces and it will always be 10 characters. Remove trailing/leading spaces and then check the len()

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.

I'm not quite sure what you mean. Can you explain?

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.

Can you tell me how to do it?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry, I thought it was necessary, but I tried it and saw that SQL is restricting to insert even when inserting spaces.

Comment thread 1. table.sql Outdated
SSN char (10) not null constraint ck_ssn_10_characters check (len (SSN) = 10)
constraint u_SSN_must_be_Unique unique,
DOB date not null ,
DateOfEnlistment date 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 future dates.

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
PlaceOfResidence varchar (50) not null constraint ck_POR_cannot_be_blank check (PlaceOfResidence <> ''),
ServiceUnit varchar(20) not null constraint ck_serviceunit_navy_land_or_air check (ServiceUnit in ('Navy', 'Ground Force', 'Air Force')),
SoldierRank varchar (50) not null constraint ck_soldier_rank_cannot_be_blank check (SoldierRank <> ''),
IQLevel int 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.

Cannot be negative. And maybe don't allow more than max IQ level.

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.

What is the max IQ level? I tried to google but didn't get concrete answer

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's ok, maybe use 200

Comment thread 3 reports.sql Outdated
order by IQLevel desc

--2) I need a list of all soldiers sorted by age at enlistment from high to low. Do not include columns that are not relevant to this list.
select LastName, FirstName, Age= year(DateOfEnlistment)-year(DOB)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There's a better way to check diff in dates.

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.

I fixed this

Comment thread 3 reports.sql
where YearRange = '2017-2019'
union select Recruitment =concat(YearRange, ', ', FirstName, ' ', LastName, ' - ', SSN, ' ', '(', DateOfEnlistment, ')', ', ', ServiceUnit)
from soldiers s
where YearRange = '2020-2022'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe sort in order

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.

In order of what?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For example, year. It should be in sensible order.

Comment thread 1. table.sql Outdated
ServiceUnit varchar(20) not null constraint ck_serviceunit_navy_land_or_air check (ServiceUnit in ('Navy', 'Ground Force', 'Air Force')),
SoldierRank varchar (50) not null constraint ck_soldier_rank_cannot_be_blank check (SoldierRank <> ''),
IQLevel int not null,
constraint ck_Soldier_must_be_at_least_17 check (year(DateOfEnlistment) - year(DOB) >=17)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There's a better way to check diff in dates.

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.

I fixed this

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.

Looks good, see comments. No need to resubmit.

Comment thread 1. table.sql
SoldierID int not null identity primary key,
FirstName varchar (30) not null constraint first_name_cannot_be_blank check (FirstName <> ''),
LastName varchar (30) not null constraint last_name_cannot_be_blank check (LastName <> ''),
SSN char (10) not null constraint ck_ssn_10_characters check (len (SSN) = 10)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry, I thought it was necessary, but I tried it and saw that SQL is restricting to insert even when inserting spaces.

Comment thread 1. table.sql Outdated
PlaceOfResidence varchar (50) not null constraint ck_POR_cannot_be_blank check (PlaceOfResidence <> ''),
ServiceUnit varchar(20) not null constraint ck_serviceunit_navy_land_or_air check (ServiceUnit in ('Navy', 'Ground Force', 'Air Force')),
SoldierRank varchar (50) not null constraint ck_soldier_rank_cannot_be_blank check (SoldierRank <> ''),
IQLevel int 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.

It's ok, maybe use 200

Comment thread 3 reports.sql
where YearRange = '2017-2019'
union select Recruitment =concat(YearRange, ', ', FirstName, ' ', LastName, ' - ', SSN, ' ', '(', DateOfEnlistment, ')', ', ', ServiceUnit)
from soldiers s
where YearRange = '2020-2022'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For example, year. It should be in sensible order.

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