Skip to content

Instantly share code, notes, and snippets.

@gaurav274
Created October 8, 2024 05:25
Show Gist options
  • Save gaurav274/1e44f6aa0fc4c4bd1547d9e0d6660f2f to your computer and use it in GitHub Desktop.
Save gaurav274/1e44f6aa0fc4c4bd1547d9e0d6660f2f to your computer and use it in GitHub Desktop.
CREATE TABLE CBSA
(
CBSA INTEGER primary key, -- description: the code of the cbsa officer
CBSA_name TEXT, -- examples: `Lima, OH`, `Pittsfield, MA`, `Johnstown, PA`, `Salisbury, MD-DE`, `Somerset, KY`, `Alpena, MI`, `Midland, MI`, `Reading, PA`, `Bloomington, IN`, `Lewistown, PA`, `Milledgeville, GA`, `Battle Creek, MI`, `Johnson City, TN`, `Marietta, OH`, `Sturgis, MI`, `Brownsville, TN`, `New Castle, PA`, `Picayune, MS`, `Jacksonville, FL`, `Sandusky, OH`, `Corning, NY`, `Sumter, SC`, `Dayton, TN`, `Anchorage, AK`, `Madisonville, KY`, `Tiffin, OH`, `Huntingdon, PA`, `Newport, TN`, `Danville, VA`, `Boston-Cambridge-Newton, MA-NH`, `Parkersburg-Vienna, WV`, `Roanoke Rapids, NC`, `Natchez, MS-LA`, `Hagerstown-Martinsburg, MD-WV`, `Athens-Clarke County, GA`, `Kalamazoo-Portage, MI`, `New Haven-Milford, CT`, `Bangor, ME`, `Crossville, TN`, `State College, PA`, `Portland-South Portland, ME`, `Homosassa Springs, FL`, `Elmira, NY`, `Springfield, MA`, `Virginia Beach-Norfolk-Newport News, VA-NC`, `Atmore, AL`, `Goldsboro, NC`, `Ludington, MI`, `Dothan, AL`, `Lewiston-Auburn, ME`| `cbsa name` description: the name and the position of the cbsa officer
CBSA_type TEXT, -- examples: `Micro`, `Metro`| `cbsa type` description: the office type of the officer
);
CREATE TABLE state
(
abbreviation TEXT primary key, -- description: the abbreviation of the state name
name TEXT, -- examples: `Virgin Islands`, `Ohio`, `Utah`, `Guam`, `Maryland`, `South Dakota`, `Nebraska`, `Connecticut`, `Georgia`, `Pennsylvania`, `Wisconsin`, `West Virginia`, `Missouri`, `Idaho`, `Texas`, `Kansas`, `Iowa`, `Minnesota`, `Puerto Rico`, `Maine`, `Tennessee`, `South Carolina`, `New Mexico`, `Montana`, `Washington`, `New Hampshire`, `Florida`, `California`, `Armed Forces Pacific`, `Oregon`, `District of Columbia`, `Arizona`, `New Jersey`, `Michigan`, `American Samoa`, `Oklahoma`, `Illinois`, `Nevada`, `Marshall Islands`, `Wyoming`, `Armed Forces Americas`, `Arkansas`, `Vermont`, `Federated States of Micronesia`, `Massachusetts`, `Armed Forces Europe`, `Alabama`, `Indiana`, `Kentucky`, `Virginia`| description: the state name
);
CREATE TABLE congress
(
cognress_rep_id TEXT primary key, -- `congress representative id` description: the representative id of congress representatives
first_name TEXT, -- examples: `Horsford`, `Ruiz`, `Larson`, `McCaul`, `Thompson`, `Gutierrez`, `Shuster`, `Latta`, `Black`, `Salmon`, `Beutler`, `Carney`, `Westmoreland`, `Beatty`, `McAllister`, `Gibbs`, `Cramer`, `Hartzler`, `Cruz`, `Nunnelee`, `Udall`, `Courtney`, `Cummings`, `Cassidy`, `Cooper`, `Brownley`, `Costa`, `Gardner`, `McKeon`, `Labrador`, `Terry`, `Aderholt`, `Ruppersberger`, `Griffin`, `Valadao`, `Isakson`, `Perlmutter`, `Sanders`, `Neugebauer`, `Bilirakis`, `Hultgren`, `Bustos`, `Matheson`, `Yarmuth`, `Cochran`, `Joyce`, `Norton`, `Bridenstine`, `Durbin`, `McKinley`| `first name` description: the first name of the congress representative
last_name TEXT, -- examples: `Raul`, `Lisa`, `Chris`, `Michael R`, `Mo`, `Robert E`, `Juan`, `Charlie`, `Doug`, `Suzanne`, `Jerrold`, `Marco`, `Lynn`, `Lindsey`, `Roy`, `Ben Ray`, `Nick`, `Kyrsten`, `Bruce`, `Gregory W`, `Hal`, `John A`, `Candice S`, `Grace`, `Kristi`, `Douglas L`, `Betty`, `William L Jr`, `Earl`, `Martha`, `Daniel`, `Kelly`, `Richard C`, `Stephen F`, `Kurt`, `Cory`, `Randy`, `Susan`, `Rick`, `Kay`, `Steve`, `Gregg`, `Lois J`, `Dutch`, `Mazie K`, `Frederica`, `Joseph`, `Rand`, `Robert A`, `Pete`| `last name` description: the last name of the congress representative
CID TEXT, -- examples: `N00005883`, `N00031741`, `N00031672`, `N00032029`, `N00001619`, `N00002424`, `N00013823`, `N00005282`, `N00026043`, `N00004436`, `N00027894`, `N00001285`, `N00003209`, `N00031513`, `N00030880`, `N00005870`, `N00031857`, `N00028418`, `N00033532`, `N00001024`, `N00026160`, `N00006236`, `N00030910`, `N00030581`, `N00034453`, `N00004572`, `N00026148`, `N00027035`, `N00032546`, `N00027848`, `N00006954`, `N00013873`, `N00029444`, `N00031820`, `N00024866`, `N00001102`, `N00002577`, `N00001758`, `N00000898`, `N00024753`, `N00030836`, `N00031141`, `N00026710`, `N00031938`, `N00001811`, `N00034044`, `N00034224`, `N00032441`, `N00029835`, `N00008122`| description: the unique identifier for the congress representative
party TEXT, -- examples: `Republican`, `Democrat`, `Independent`| description: the party of the representative
state TEXT, -- examples: `North Carolina`, `Massachusetts`, `California`, `Mississippi`, `Georgia`, `Oklahoma`, `West Virginia`, `American Samoa`, `Oregon`, `Vermont`, `Kansas`, `Maine`, `Michigan`, `Colorado`, `Washington`, `Wisconsin`, `Indiana`, `Idaho`, `Nevada`, `Wyoming`, `Hawaii`, `Virginia`, `Arizona`, `District of Columbia`, `Pennsylvania`, `Guam`, `South Carolina`, `New Mexico`, `Minnesota`, `Iowa`, `North Dakota`, `Missouri`, `South Dakota`, `Maryland`, `Alaska`, `New Hampshire`, `Tennessee`, `Louisiana`, `Alabama`, `Illinois`, `Kentucky`, `Arkansas`, `Utah`, `Rhode Island`, `Florida`, `Puerto Rico`, `New York`, `New Jersey`, `Montana`, `Ohio`| description: the state that the representative is from
abbreviation TEXT, -- description: the abbreviation of the state
House TEXT, -- examples: `House of Repsentatives`, `Senate`| description: the house that the representative is from
District INTEGER, -- description: the id of the district that the representative represents value description: The state is divided into different districts. The districts under the same state will be numbered uniformly.
'NA' means that the state is not divided into districts.
land_area REAL, -- `land area` description: the land area of the district
foreign key (abbreviation) references state(abbreviation),
);
CREATE TABLE zip_data
(
zip_code INTEGER primary key, -- `zip code` description: the zip code of the postal point
city TEXT, -- examples: `Seatonville`, `Hedgesville`, `Tulelake`, `Napavine`, `Robertsdale`, `Analomink`, `Asher`, `Minster`, `Egg Harbor`, `Walden`, `Hadlyme`, `Mayfield`, `Apple Creek`, `Sauk Rapids`, `Saffell`, `Canova`, `Mooresburg`, `Beltsville`, `Lequire`, `Brush Creek`, `Shell`, `Palmer`, `Liberty Mills`, `Macks Inn`, `Venice`, `Riverhead`, `Animas`, `Saint Stephens Church`, `Formoso`, `Brethren`, `Bass Harbor`, `Lloyd`, `Hale`, `Leonard`, `Waterford Works`, `Slatedale`, `Ladson`, `Paron`, `Whitmore Lake`, `Gackle`, `Deary`, `Jensen`, `South Naknek`, `Pownal`, `Lytle Creek`, `Calvert`, `Le Mars`, `Washington Mills`, `Skellytown`, `Hartwick`| description: the city where the postal point locates
state TEXT, -- examples: `CO`, `FM`, `ID`, `TN`, `GU`, `DC`, `NM`, `HI`, `IN`, `MT`, `VA`, `UT`, `FL`, `AL`, `AS`, `NC`, `RI`, `TX`, `OR`, `AP`, `VT`, `NY`, `NE`, `AR`, `AE`, `KS`, `NJ`, `OH`, `LA`, `WV`, `NH`, `MP`, `PA`, `VI`, `PR`, `SD`, `MH`, `IL`, `CA`, `CT`, `NV`, `MO`, `KY`, `WA`, `AK`, `SC`, `MA`, `WI`, `OK`, `MD`| description: the state of the city
multi_county TEXT, -- examples: `No`, `Yes`| `multi country` description: whether the country that the city belongs to is multi_country value description: The meaning of multi_country is consisting of or involving multiple countries.
type TEXT, -- examples: `Unique Post Office`, `Post Office`, `P.O. Box Only`, `Branch`, `Non Postal Community Name`, `Community Post Office `, `Branch-Unique`, `Non Postal Community Name-Unique`, `APO/FPO Military`| description: the type of the postal point
organization TEXT, -- examples: `Peoria Journal Star`, `Montg, Mtgy, State Of Alabama Income Tax`, `University Of Cincinnati`, `Westminster College`, `Us Copyright Office`, `National Pen Company`, `Federal Energy Reg Comm`, `Comptroller Of The Treasury`, `Howard Univ`, `Bell South`, `La St Univ, University`, `National Right To Work Comm`, `Nevada Employment Security`, `Kent State University`, `Agricultural Census`, `St Petersburg`, `Employers Health Insure Cos, Employers Hlt Ins Co`, `Nestle`, `Fingerhut Sweepstakes`, `K O A`, `Business Reply Firm Zip`, `Qvc`, `Capital One`, `Duquesne Light Co`, `Intermountain Gas Co`, `Huntington National Bank`, `University Of Sc, Usc`, `Chas, The College Of Charleston`, `Scholastics Inc`, `Ks Dept Of Revenue Vehicles`, `University Of Maine`, `Calif State University Chico`, `Idaho State Tax Commission`, `Champion Spark Plug`, `Court Of Military Appeals`, `Dept Of Defense, Dod`, `Herrschners`, `Univ Of Tn, University Of Tn`, `Bank Of New York`, `Space & Naval Warfare System`, `Bank Of New York, Manhattan, Ny, Nyc`, `San Diego Water Utilities`, `Creighton Univ`, `Sd State Univ, South Dakota State Univ`, `Washington Intel Bur`, `Ill Dept Public Health`, `Bank Of America`, `National Security Counsel`, `Bristol Merchandise Return`, `We Energies`| description: the organization to which the postal point belongs value description: 'No data' means the postal point is not affiliated with any organization
time_zone TEXT, -- `time zone` description: the time zone of the postal point location
daylight_savings TEXT, -- examples: `Yes`, `No`| `daylight savings` description: whether the location implements daylight savings value description: Daylight saving is the practice of advancing clocks (typically by one hour) during warmer months so that darkness falls at a later clock time. As a result, there is one 23-hour day in late winter or early spring and one 25-hour day in autumn.
latitude REAL, -- description: the latitude of the postal point location
longitude REAL, -- description: the longitude of the postal point location
elevation INTEGER, -- description: the elevation of the postal point location
state_fips INTEGER, -- `state fips` description: state-level FIPS code
county_fips INTEGER, -- `country fips` description: country-level FIPS code value description: FIPS codes are numbers that uniquely identify geographic areas. The number of digits in FIPS codes varies depending on the level of geography.
region TEXT, -- examples: `Northeast`, `South`, `Midwest`, `West`| description: the region where the postal point locates
division TEXT, -- examples: `Middle Atlantic`, `New England`, `South Atlantic`, `East South Central`, `East North Central`, `West North Central`, `Mountain`, `West South Central`, `Pacific`| description: the division of the organization
population_2020 INTEGER, -- `population 2020` description: the population of the residential area in 2020 value description: 'No data' means that the postal point is not affiliated with any organization. Or the organization has no division.
population_2010 INTEGER, -- `population 2010` description: the population of the residential area in 2010
households INTEGER, -- description: the number of the households in the residential area
avg_house_value INTEGER, -- `average house value` description: the average house value in the residential area
avg_income_per_household INTEGER, -- `average income per household` description: the average income per household in the residential area
persons_per_household REAL, -- `persons per household` description: the number of persons per household residential area
white_population INTEGER, -- `white population` description: the population of white people in the residential area
black_population INTEGER, -- `black population` description: the population of black people in the residential area
hispanic_population INTEGER, -- `Hispanic population` description: the population of Hispanic people in the residential area
asian_population INTEGER, -- `Asian population` description: the population of Asian people in the residential area
american_indian_population INTEGER, -- `American Indian population` description: the population of American Indian people in the residential area
hawaiian_population INTEGER, -- `Hawaiian population` description: the population of Hawaiian people in the residential area
other_population INTEGER, -- `other population` description: the population of other races in the residential area
male_population INTEGER, -- `male population` description: the population of males in the residential area
female_population INTEGER, -- `female population` description: the population of females in the residential area
median_age REAL, -- `median age` description: the median age of the residential area value description: gender ratio in the residential area = male_population / female_population if female_population != 0
male_median_age REAL, -- `male median age` description: the male median age in the residential area
female_median_age REAL, -- `female median age` description: the female median age in the residential area
residential_mailboxes INTEGER, -- `residential mailboxes` description: the number of residential mailboxes in the residential area
business_mailboxes INTEGER, -- `business mailboxes` description: the number of business mailboxes in the residential area
total_delivery_receptacles INTEGER, -- `total delivery receptacles` description: the total number of delivery receptacles
businesses INTEGER, -- description: the number of businesses in the residential area
"1st_quarter_payroll" INTEGER, -- `1st quarter payroll` description: the total wages reported in the 1st quarter payroll report of the residential area
annual_payroll INTEGER, -- `annual payroll` description: the total wages reported in the annual payroll report of the residential area
employees INTEGER, -- description: the number of employees in the residential area value description: Employers must submit periodic payroll reports to the Internal Revenue Service and state taxing authority. The report is used by employers to report wage information.
water_area REAL, -- `water area` description: the water area of the residential area
land_area REAL, -- `land area` description: the land area of the residential area
single_family_delivery_units INTEGER, -- `single-family delivery units` description: the number of single-family delivery units in the residential area
multi_family_delivery_units INTEGER, -- `multi-family delivery units` description: the number of single-family delivery units in the residential area value description: A single-family unit can be described as a single unit that accommodates only one family or tenant at a time on rent.
total_beneficiaries INTEGER, -- `total beneficiaries` description: the total number of beneficiaries of the postal service value description: multi-family units are usually under a greater surface area with the capacity to accommodate more than one tenant or multiple families on rent at the same time
retired_workers INTEGER, -- `retired workers` description: the number of retired workers in the residential area
disabled_workers INTEGER, -- `disable workers` description: the number of disabled workers in the residential area
parents_and_widowed INTEGER, -- `parents and widowed` description: the number of parents and widowed in the residential area
spouses INTEGER, -- description: the number of spouses in the residential area
children INTEGER, -- description: the number of children in the residential area
over_65 INTEGER, -- `over 65` description: the number of people whose age is over 65 in the residential area
monthly_benefits_all INTEGER, -- `monthly benefits all` description: all benefit payments by month value description: no. of over_65 can refer to elders. Higher means more elders
if the ratio: over_65 / children is higher: the aging is more serious.
monthly_benefits_retired_workers INTEGER, -- `monthly benefits retired workers` description: monthly benefit payments for retired workers value description: usd
monthly_benefits_widowed INTEGER, -- `monthly benefits widowed` description: monthly benefit payments for retired workers
CBSA INTEGER, -- description: the code of the cbsa officer
foreign key (state) references state(abbreviation),
foreign key (CBSA) references CBSA(CBSA),
);
CREATE TABLE alias
(
zip_code INTEGER primary key, -- `zip code` description: the zip code of the alias
alias TEXT, -- examples: `Croghan`, `Gratis`, `Harlowton`, `Bay Springs`, `Clarkia`, `Little River`, `Fritch`, `Unity`, `Ghent`, `Bois D Arc`, `Avon By The Sea`, `Couch`, `West Rutland`, `De Leon Springs`, `Tillman`, `Teec Nos Pos`, `Lafayette`, `Sinai`, `South Gardiner`, `Wadley`, `Quanah`, `Mead`, `Laguna`, `Hendricks`, `Stites`, `Earth City`, `Center Point`, `Spanish Fork`, `Haswell`, `Jonesboro`, `Easton`, `Busy`, `Kapaau`, `Beaverville`, `Suring`, `Glendive`, `Cedar Vale`, `Toast`, `Eastville`, `Deale`, `Groom`, `Fieldale`, `Moyie Springs`, `Taylors Falls`, `Abita Springs`, `Norwich`, `Elk Garden`, `Nacogdoches`, `Reeves`, `Cross River`| description: the alias of the city
foreign key (zip_code) references zip_data(zip_code),
);
CREATE TABLE area_code
(
zip_code INTEGER, -- `zip code` description: the zip code of the area
area_code INTEGER, -- `area code` description: the code of the area
primary key (zip_code, area_code), --
foreign key (zip_code) references zip_data(zip_code),
);
CREATE TABLE avoid
(
zip_code INTEGER, -- `zip code` description: the zip code of the bad alias
bad_alias TEXT, -- `bad alias` description: the bad alias
primary key (zip_code, bad_alias), --
foreign key (zip_code) references zip_data(zip_code),
);
CREATE TABLE country
(
zip_code INTEGER, -- `zip code` description: the zip code of the state in the country
county TEXT, -- `country` description: the country
state TEXT, -- examples: `WY`, `DC`, `MN`, `AL`, `MA`, `VI`, `TN`, `MS`, `MD`, `CO`, `GU`, `SD`, `NY`, `WA`, `PR`, `OH`, `WI`, `AZ`, `IN`, `CT`, `SC`, `RI`, `ME`, `MT`, `ND`, `ID`, `KS`, `PW`, `IL`, `MP`, `KY`, `FM`, `NJ`, `WV`, `VA`, `OR`, `MO`, `UT`, `NH`, `FL`, `CA`, `TX`, `IA`, `HI`, `DE`, `NE`, `MI`, `MH`, `NC`, `NV`| description: the state of the country
primary key (zip_code, county), --
foreign key (zip_code) references zip_data(zip_code),
foreign key (state) references state(abbreviation),
);
CREATE TABLE zip_congress
(
zip_code INTEGER, -- `zip code` description: the zip code of the district
district TEXT, -- description: the district
primary key (zip_code, district), --
foreign key (district) references congress(cognress_rep_id),
foreign key (zip_code) references zip_data(zip_code),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment