![]() |
|
|
#1 | ||
|
Mascot
Join Date: Jul 2016
|
SQL and FOF
So I taught myself the basics of SQL over the Easter weekend.
I've been through the archive here and can't see much guidance on using SQL to go through the FOF CSVs, other than various commish threads getting into the details of how they put websites together. Am I missing any obvious resources that will help me learn this faster? So far all I have done is generate 100 years of history, imported it into SQL and I'm playing around with it. |
||
|
|
|
|
|
#2 | |
|
Morgado's Favorite Forum Fascist
Join Date: Oct 2000
Location: Greensboro, NC
|
Quote:
Point being, a LOT can be done with being self-taught with a nudge here and there to help get you through some sticky points. My #1 bit of advice would be "try to pull information that you want to see." In other words, if it's "fun," it'll give you more of a sense of accomplishment and keep you motivated to learn more.
__________________
The media don't understand the kinds of problems and pressures 54 million come wit'! Last edited by Ben E Lou : 04-25-2017 at 10:59 AM. |
|
|
|
|
|
|
#3 |
|
Morgado's Favorite Forum Fascist
Join Date: Oct 2000
Location: Greensboro, NC
|
Dola:
For clarification, are you using MySQL or SQL? MySQL is the free version that comes with many web hosting plans and can also be installed locally on your machine for free. If you'reusing MySQL, I'd *HIGHLY* recommend the aforementioned "Dummies" book.
__________________
The media don't understand the kinds of problems and pressures 54 million come wit'! |
|
|
|
|
|
#4 |
|
Mascot
Join Date: Jul 2016
|
Thanks Ben.
Yeah I'm using MySQL now - I started with the SQlite add-on within Firefox to learn a little about how queries worked, then once I'd got that into my head I put it all up in a webserver and figured out how to set up phpmyadmin. Will find a copy of the book. (and FWIW for fellow newbies, I've found a couple of primers from the sabermetrics world useful here: This article which piqued my interest, and then I found this online course which has got me onto the learning curve.) |
|
|
|
|
|
#5 |
|
n00b
Join Date: Aug 2015
|
I'm a software developer, who uses SQL on a daily basis. Feel free to PM me any questions you might have, I'd be happy to help.
|
|
|
|
|
|
#6 |
|
Mascot
Join Date: Jul 2016
|
Cool, thanks. The more I get into this, the more interesting it gets. Starting to think I should have done it for a living!
|
|
|
|
|
|
#7 |
|
Mascot
Join Date: Jul 2005
|
|
|
|
|
|
|
#8 |
|
n00b
Join Date: Jul 2015
|
Ok SQL guys, I'm trying to create a query which helps me find the guys that are affinities for one of my players. How would I join the players information with the calendar so I don't get duplicates? There's nothing to join on like a player id so I'm a little confused. For example I've got a player born on 1/26 (I catted the month and day fields from the player information table get the bday field. The other 3 fields are from a calendar table I created)
+-------+-------+-------+-------------+ | bday | begin | end | sign | +-------+-------+-------+-------------+ | 01/26 | 01/21 | 02/18 | Aquarius | | 01/26 | 02/19 | 03/20 | Pisces | There's 12 lines that show his bday and the other signs. He falls into the Aquarius category obviously, so how would I only display that? |
|
|
|
|
|
#9 |
|
n00b
Join Date: Aug 2015
|
So first I'd change your calendar table to look like this:
CalendarID BeginMonth BeginDay EndMonth EndDay StarSign Then you can query like this: SELECT info.First_Name, info.Last_Name, info.Month_Born, info.Day_Born, info.Year_Born, c.SignName, c.* FROM dbo.player_information info INNER JOIN dbo.Calendar c ON (info.Month_Born = c.BeginMonth AND info.Day_Born> c.BeginDay) OR (info.Month_Born = c.EndMonth AND info.Day_Born < c.EndDay) WHERE info.Player_ID = {the player_id of the player in question} That get's you the sign of any player you want. If you want to get all players with affinities to that sign, it will be a different query, and I'll post that after I get back from my daughters soccer practice. |
|
|
|
|
|
#10 |
|
n00b
Join Date: Aug 2015
|
So if you want to get all the affinities for a player you can do this.
Say your player is Aquarius, so you want all the players that are Libra or Capricorn, you could do this SELECT info.First_Name, info.Last_Name, info.Month_Born, info.Day_Born, info.Year_Born, info.Position, c.SignName FROM dbo.player_information info INNER JOIN dbo.Calendar c ON (info.Month_Born = c.BeginMonth AND info.Day_Born> c.BeginDay) OR (info.Month_Born = c.EndMonth AND info.Day_Born < c.EndDay) WHERE (c.SignName = 'Libra' OR c.SignName = 'Capricorn') |
|
|
|
|
|
#11 |
|
n00b
Join Date: Aug 2015
|
And if you want just one position that matches affinity you could do this:
SELECT info.First_Name, info.Last_Name, info.Month_Born, info.Day_Born, info.Year_Born, info.Position, c.SignName FROM dbo.player_information info INNER JOIN dbo.Calendar c ON (info.Month_Born = c.BeginMonth AND info.Day_Born> c.BeginDay) OR (info.Month_Born = c.EndMonth AND info.Day_Born < c.EndDay) WHERE (c.SignName = 'Libra' OR c.SignName = 'Capricorn') AND info.Position = 'RB' Which gets all Running backs that are an affinity |
|
|
|
|
|
#12 |
|
n00b
Join Date: Aug 2015
|
And honestly I would set up my calendar table like this:
CalendarID, BeginMonth, BeginDay, EndMonth, EndDay, StarSign, ConflictID, Affnity1ID, Affinity2ID Where ConflictID, Affiity1ID, and Affinity2ID are the ID's of the signs that correspond with that sign. So the table row for Aquarius would look like this: 1, 1, 21, 2, 18, 'Aquarius', 2, 9, 12 where the ID of 9 corresponds to Libra, 12 corresponds to Capricorn, and 2 corresponds to Pisces. |
|
|
|
|
|
#13 |
|
Mascot
Join Date: Jul 2016
|
Woah. Bookmarking this. Right now I do it all in Excel and it's way more convoluted than this. Thanks.
A simpler question if I may. What's the best way to get all the csv tables into MySQL? Ideally I want to be able to click on 'export data' and 'export scouting data' in-game to refresh the CSVs, then somehow automatically update all that into SQL with one click / minimum hassle. Is there a way to do that? |
|
|
|
|
|
#14 |
|
n00b
Join Date: Aug 2015
|
I use MSSQL instead of MYSQL, and I have my own scripts that do the import.
There is this thread: DBUpdater 2 For FOF7 - Front Office Football Central That includes a tool for importing the csv's into MYSQL. It says it's for FOF7, but the csv tables haven't changed much between versions. I think it might be the one Ben uses for his online leagues. |
|
|
|
|
|
#15 |
|
n00b
Join Date: Jul 2015
|
Cleancoder this is great stuff. Thanks so much! I never thought of setting up the calendar table like that. ☺️
|
|
|
|
|
|
#16 | |
|
Morgado's Favorite Forum Fascist
Join Date: Oct 2000
Location: Greensboro, NC
|
Quote:
__________________
The media don't understand the kinds of problems and pressures 54 million come wit'! |
|
|
|
|
|
|
#17 |
|
n00b
Join Date: Jul 2015
|
I'd definitely be interested in it.
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|