Presentation is loading. Please wait.

Presentation is loading. Please wait.

MySQL Importing and creating a database. CSV (Comma Separated Values) file CSV = Comma Separated Values – they are simple text files containing data which.

Similar presentations


Presentation on theme: "MySQL Importing and creating a database. CSV (Comma Separated Values) file CSV = Comma Separated Values – they are simple text files containing data which."— Presentation transcript:

1 MySQL Importing and creating a database

2 CSV (Comma Separated Values) file CSV = Comma Separated Values – they are simple text files containing data which can be imported into a database or spreadsheet A CSV can be created using a spreadsheet in Excel (Save as CSV) In the CSV file, the data is delimited by a comma. Delimiters separate the data. Other types of delimiters include a semi-colon or tab Spreadsheet (Excel) CSV file (opened in Notepad)

3 MySQL Import Functioon CSV files can be imported into a database, spreadsheet, etc. (Excel files may also be imported, but CSV files are simpler and more universal) Create spreadsheet Save as CSV file Import using PHPMyAdmin

4 Step 1 - Create CSV File Create the table containing the data: 1.Copy a table with data from any web page (e.g. flight info) 2.Paste into Excel or spreadsheet (paste without formatting) 3.Make sure the table has a row of column headers, e.g. departing from, airline, flight no., etc. 4.Save as a CSV file

5 Step 2- Import CSV File to PHPMyAdmin Exercise (continued) 5.Open PHPMyAdmin on screen, open/create a database file 6.Click Import 7.Select the CSV file 8.Make sure “Use header” is selected (see below) so the first row of the table does not get accepted as part of the data. (it will use this as field names instead) 9.When the CSV file imports, a table is created with a default name, e.g. table 3

6 Step 3 – Rename the Table Continued … Select and rename the table (use Operations tab): Table renamed, e.g. flight_departures

7 Step 4 – Add Primary Key Continued … To change and edit the structure of the table, it needs a unique column identifier (primary key) Open the table structure. Add a column at the beginning of the table Use a name such as id, with type INT (length 3 digits), primary and A_I for auto increment Save

8 Step 5 - continued Each record now has a unique field (id) to identify it The PRIMARY KEY uniquely identifies each record in a database table. A primary key column cannot contain NULL values. Each table should have a primary key, and each table can have only ONE primary key. In this example the primary key is called id

9 Step 6 (final) – Edit Structure You can then edit the structure and field names and data type (int for id, var char for basic information, and time for flight times Here is some example data inside the table

10 Summary Data can be created in a different format and imported into MySQL MySQL is a fast database system enabling interaction with web pages. Further exercises (if time) A database can be exported to a file, then it becomes portable. You could use the file to transfer the database to a different PHPMyAdmin The exported database can be re-imported on a different computer. 1.Export the database in CSV format and save to a folder. 2.Import CSV file in Excel.


Download ppt "MySQL Importing and creating a database. CSV (Comma Separated Values) file CSV = Comma Separated Values – they are simple text files containing data which."

Similar presentations


Ads by Google