Topic - Unit 5 - Team Problem Solving Activity - Unit 5 Group 3
Topic - Unit 5 - Team Problem Solving Activity - Unit 5 Group 3
3 19
Unit 5: Team Problem Solving Activity - Unit 5 Group 3
From CIS622
Introduction
A fluent professional in this field can easily recognize
concepts across different coding languages. The python
pandas library works a lot like SQL, which you are building a
proficiency in. For this activity, you will practice your SQL
and then research why someone might used python over
SQL for a similar task.
Directions
1. As a group build the code below in SQL:
1. Create two new tables that are related with a primary
and foreign key.
2. Add data to both tables.
3. Join the two tables.
4. Two additional actions of your groups choosing.
Due Dates
Participate in the discussion at least three different days
https://canvas.park.edu/groups/26889/discussion_topics/1512468 1/13
11/18/22, 8:39 AM Topic: Unit 5: Team Problem Solving Activity - Unit 5 Group 3
Reply
Tuesday
Hi Team,
This week we are tasked to code in SQL. We need to create tables and that are mapped with
foreign and primary keys. So on what data we can create the tables. Does anyone have
anything specific in mind or we can just go with random data. In my view since it is only two
tables we need to embed all the information in those two. So what about US states and
population in each state?
Reply
Tuesday
Pavankalyan,
I don’t know what Lauren means by “additional actions of our choosing”, but to do this I
have an idea. Why not do three tables: one with our names and an ID, an event table that
is event ID and a date we had our favorite meal and the ID of what we had, then a third
table which is a list of our favorite meals. And an ID for each. We set up our relationships
and then build 2 queries: the most common meal we’ve eaten and meals we’ve not tried.
So my dataset could be
https://canvas.park.edu/groups/26889/discussion_topics/1512468 2/13
11/18/22, 8:39 AM Topic: Unit 5: Team Problem Solving Activity - Unit 5 Group 3
tblEvent: 1, 11/4/2022, 2
tblMeal: 2, Macaroni and Cheese
If you all give me a list of 5 foods each and 2 dates, I will code the SQL and post the
scripts here for your review.
Pavankalyan, please have a look at the requirements and let me know what you think of
my take.
Reply
Tuesday
Hi Brown,
I think the idea of two additional actions can be adding of more tables as well but not
sure.
The idea which you have proposed is good. So in our tables we are going to have
primary keys for all tables such as person_id, event_id, and meal_id. Am I correct?
List of foods
tblPerson: 1, Pavan
tblEvent: 1, 11/11/2022, 3
tblMeal: 4, Pista
tblPerson: 2, Pavan
tblEvent: 2, 11/9/2022, 2
tblPerson: 3, Pavan
tblEvent: 3, 9/9/2022, 5
https://canvas.park.edu/groups/26889/discussion_topics/1512468 3/13
11/18/22, 8:39 AM Topic: Unit 5: Team Problem Solving Activity - Unit 5 Group 3
tblPerson: 4, Kalyan
tblEvent: 1, 12/9/2022, 1
tblPerson: 5, Kalyan
tblEvent: 4, 11/5/2022, 6
tblMeal: 2, Hamburger
Reply
Tuesday
Pavankalyan,
You’re spot on with the keys! I will code this tomorrow evening and post my
script!
Reply
Wednesday
Hi Brown,
That's Awesome!
Reply
Tuesday
Hi Brown,
I agree with you idea and implementation, Sure we will go with the above three tables
tblPerson:3,Siva, Sai
tblEvent:3,11/05/2022,7
https://canvas.park.edu/groups/26889/discussion_topics/1512468 4/13
11/18/22, 8:39 AM Topic: Unit 5: Team Problem Solving Activity - Unit 5 Group 3
tblPerson:3,Siva, Sai
tblEvent:3,11/10/2022,8
tblPerson:3,Siva, Sai
tblEvent:3,11/10/2022,9
tblMeal:9,Pizza ,Softdrink
Reply
Wednesday
Hi Team ,
Thanks
Reply
Yesterday
Ravi,
I wouldn't use the DECIMAL field type if I could use FLOAT. What happens if the price for
an item is $1000? Also, if you default values to NULL, that means you can have an entry
with a PK but no other data. Is that something you would allow>
Michael
Reply
8:47am
Hi Michael ,
Decimal Is preferable in this case since the price is represented in dollars and cents.
We have made our database in a way that the output will be rendered as $1000.00
Thanks
Ravi
Reply
Yesterday
So, starting on the scripts - here is the one for our own people
-- Table: public.Person
https://canvas.park.edu/groups/26889/discussion_topics/1512468 6/13
11/18/22, 8:39 AM Topic: Unit 5: Team Problem Solving Activity - Unit 5 Group 3
TABLESPACE pg_default;
OWNER to postgres;
This is the SQL pgAdmin generates. I will post the others as I write them.
Reply
Yesterday
Event tabl
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID
);
https://canvas.park.edu/groups/26889/discussion_topics/1512468 7/13
11/18/22, 8:39 AM Topic: Unit 5: Team Problem Solving Activity - Unit 5 Group 3
OWNER to postgres;
Reply
Yesterday
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID
);
OWNER to postgres;
Reply
Yesterday
A final word on create scripts: if creating in pgAdmin's GUI, make sure you do not
select a VARCHAR field with brackets. That creates an array field.
https://canvas.park.edu/groups/26889/discussion_topics/1512468 8/13
11/18/22, 8:39 AM Topic: Unit 5: Team Problem Solving Activity - Unit 5 Group 3
I will be back later with insert statements. At this point, I have tables coded and
"joined", in that we've created foreign keys that bind tables together. When we
get to writing queries, we're going to look at JOIN statements in the script.
Reply
Yesterday
Hi Michael,
Table Person:
PersonID,Firstname ,lastname
Eg:
Table2:(Meal Date)
Meal Date
Person ID,
MealID,
Eg:
https://canvas.park.edu/groups/26889/discussion_topics/1512468 9/13
11/18/22, 8:39 AM Topic: Unit 5: Team Problem Solving Activity - Unit 5 Group 3
Table3:Meal
FoodID
MealID
FoodDescription
Table Meal :
9,7,Pizza Softdrink
Reply
Yesterday
Is this table we will use to store a person's information with the primary key as primary_id?
I have a few doubts about what COLLATE and TABLESPACE represent in the code. I am
new to SQL pgAdmin so never mind asking you this.
Reply
Yesterday
https://canvas.park.edu/groups/26889/discussion_topics/1512468 10/13
11/18/22, 8:39 AM Topic: Unit 5: Team Problem Solving Activity - Unit 5 Group 3
dripped the columns and added them back (correctly this time).
Reply
Yesterday
Hello Team
Post 1
Here I have created two tables using the sql. Here the tables are realted to the food ordering
system. Here I have connected both tables using customer_ID. We can see that in customer
table it is Primary key and in transaction table it is foregin key.
) ON [PRIMARY]
https://canvas.park.edu/groups/26889/discussion_topics/1512468 11/13
11/18/22, 8:39 AM Topic: Unit 5: Team Problem Solving Activity - Unit 5 Group 3
) ON [PRIMARY]
References
Wade. (2020). Skills wanted: Sql, Java, Python, and AWS top employers’ wish lists - [Careers].
IEEE Spectrum, 57(1), 59–59. https://doi.org/10.1109/mspec.2020.8946316
(https://doi.org/10.1109/mspec.2020.8946316)
Reply
Yesterday
Hello guys,
I am working on tables and added data in it, with primary and foreign keys.
Reply
https://canvas.park.edu/groups/26889/discussion_topics/1512468 12/13
11/18/22, 8:39 AM Topic: Unit 5: Team Problem Solving Activity - Unit 5 Group 3
9:02am
Everyone,
We now have three people working towards SQL. Can we stick to what I am putting out
there? This way, when we go to post our results Sunday, we have only one database to talk
about.
If someone is looking to code the Python version of what I am coding in SQL, or wants to take
the data set and put it into a csv file for load, I could use help there.
Reply
https://canvas.park.edu/groups/26889/discussion_topics/1512468 13/13