1 / 41

Creating a database

Creating a database. MYSQL and WAMP On LocalHost. Open phpmyadmin Create a database. Add database name. Select the DB andCreate the table. Add the fields. Click on structure and get ready to add these fields. TID – Integer, make the INDEX PRIMARY, make it autoincrement.

msearfoss
Download Presentation

Creating a database

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Creating a database MYSQL and WAMP On LocalHost

  2. Open phpmyadminCreate a database

  3. Add database name

  4. Select the DB andCreate the table

  5. Add the fields • Click on structure and get ready to add these fields. • TID – Integer, make the INDEX PRIMARY, make it autoincrement. • T_LASTNAME—char 15 • T_FIRSTNAME—char 10 • T_Room—char 5 • Set the DB engine to InnoDB

  6. Add the fields to the table

  7. The fields—Remember to change DB engine to InnoDB

  8. Display of the structure

  9. Click on the DATABASE testDBAdd the name student to create that table

  10. Add fields to STUDENT table • SID – Integer, make the INDEX PRIMARY, make it autoincrement. • S_LASTNAME—char 15 • S_FIRSTNAME—char 10 • S_Room—char 5 • S_Advisor—INT, make it indexed. You need this to make the relation. • Be sure you set the engine to InooDB

  11. The student table structure

  12. The final structure created

  13. Add a connection • We are going to create a link between the primary key TID in the teachers table and S_Advisor in the student table. • You need to click on the student table. • And you are going to click on the relation view. • You will see the list of fields for the table. Go to the field S_Advisor. You are connect that field to the entries in the teacher table. You need to select the field teachers.TID and click on save.

  14. The foreign key is in STUDENT. So open the student table structure.

  15. The result from clicking on RELATION VIEW

  16. Show the connection worked • Now we are going to add some records to the teachers table. • Then we will add records to the student table. • You will see when we try to enter records for the S_Advisor, we get a drop down list of which has the entries from the teachers table.

  17. Click on teachers table and select insert

  18. Add the data and click go

  19. To see results, click on browse

  20. Add a few student records. Notice the drop-down arrow for advisor

  21. We will look at how to tie the id numbers to the entries later in the semester. • You can only add advisors from the list provided. • See the results.

  22. Student Table Records

  23. Difference between downloaded mysql site and La Salle Sites

  24. List of differences • WAMP uses an Apache server. Your host is localhost. • system uses IIS server. Your host is csc-srv1.lasalle.edu. It is remote.

  25. Privileges • On localhost, you are an administrator. You have all privileges, so you can create users and many databases. • On csc-srv1.lasalle.edu, your privileges are limited. You are a user, so you need to login. • You have a database you can view. It is NORTHWIND. • You have a pre-defined database. The name is your login ID. You can only see your databases.

  26. You can create many different databases on localhost. • You are limited to creating only one on csc-srv1.lasalle.edu. • For either, you can export the database both the structure and the data via SQL.

  27. You can move a lasalle database to your home by exporting it, saving the exported SQL and then inserting it into the localhost. • Try exporting NORTHWIND from lasalle to your home database. You can use this to test the feature. • If you destroy the NORTHWIND at home, you can always rebuild it by reloading the SQL.

  28. LA SALLE MYSQL • To get to the lasalle version of mysql, you need to type the following link into your browser • http://csc-srv1.lasalle.edu:8080/ • You will get a login request. • The ID is your portal ID. • Your password is your student id.

  29. Login Screen

  30. Databases • You have access to 3 databases here • NORTHWIND • One with your login ID • Information_schema

  31. What can I do • From here you can • Browse NORTHWIND or INFORMATION_SCHEMA • Create tables and relations in yournameDB • Add relations and records in yournameDB

  32. Look at the differences • What is easily visible here? • What is the engine used for the tables? • In LOCALHOST • In csc-srv1.lasalle.edu

  33. mysqlworkbench • This tool allows you to see pictures of your tables and connections. • There is a link in the website for you to download the tool. It is free ware. • There is a PDF file that tells you how to connect it to your lasalle mysqldatabase. • Each server database is called an instance. • Try getting the tool to connect.

  34. This tool is useful for showing the relations in your databases. • You can also use the tool to build the database tables and connections. • We will talk about that later this semester.

  35. You should walk through this example and try to create these tables both on your localhost and in your database on the lasalle server. • We will be working much more with this over the next few weeks.

More Related