The conceptual process of populating related tables in a database (MySql) from a CSV file
Posted
by user322772
on Stack Overflow
See other posts from Stack Overflow
or by user322772
Published on 2010-04-21T23:59:05Z
Indexed on
2010/04/22
0:03 UTC
Read the original article
Hit count: 261
I'm new to relational databases and all the material I've read covered primary and foreign keys, normal forms, and joins but left out to populate the database once it's created.
How do you import a CSV file so the fields match their related table?
Say you were tying to build a beer database and had a CSV file with each line as a record.
Header: brewer, beer_name, country, city, state, beer_category, beer_type, alcohol_content
Record 1: Anheuser-Busch, Budweiser, United States, St. Louis, Mo, Pale lager, Regular, 5.0%
Record 2: Anheuser-Busch, Bud Light, United States, St. Louis, Mo, Pale lager Light, 4.2%
Record 3: Miller Brewing Company, Miller Lite, United States, Milwaukee, WI, Pale lager, Light, 4.2%
You can create a "Brewer" table and a "Beer" table. When importing how does you connect the primary keys between the tables?
© Stack Overflow or respective owner