+ All Categories
Home > Software > MySQL Database with phpMyAdmin

MySQL Database with phpMyAdmin

Date post: 08-Jul-2015
Category:
Upload: karwan-mustafa-kareem
View: 1,652 times
Download: 2 times
Share this document with a friend
Description:
In today's high technology environment, organizations are becoming more and more dependent on their information systems. The public is increasingly concerned about the proper use of data and information. Most Organizations like banks, airlines, markets, manufactures and universities widely used computer systems to manage, manipulate and process their information. Many of today's most widely used computer systems are database applications, for example, Amazon, which was built on top of MySQL. Database application is involved like everywhere in our world, it touches all aspects of our lives. A database application is a computer program whose primary purpose is entering and retrieving information from a computerized database. Early examples of database applications were accounting systems and airline reservations systems. The aim of this course is to explore fundamentals of database application related to MySQL, phpMyAdmin, MySQL command lines, apache server and PHP Maker. It details the relational database principles. It shows how to build and develop database application with web interface. Upon completion of this course, computer students will have gained knowledge of database application concepts and the ability to:  Must know the basic concepts related relational database application.  Must know how to manage relational database via using MySQL command line and phpMyAdmin.  Must know how to build database application with web interface by using MySQL and PHPMaker. A combination of lectures and practical sessions will be used in this course in order to achieve the aim of the course. By MSc. Karwan Mustafa Kareem
70
Database application Chapter 2: MySQL Database and PhpMyAdmin Faculty of Physical and Basic Education Computer Science By: Msc . Karwan M. Kareem 2014 - 2015 © University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015 1
Transcript
Page 1: MySQL Database with  phpMyAdmin

Database applicationChapter 2: MySQL Database and PhpMyAdmin

Faculty of Physical and Basic Education

Computer Science

By: Msc. Karwan M. Kareem2014 - 2015

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015 1

Page 2: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Topics

Familiarizing yourself with phpMyAdmin.

Creating tables in a MySQL database with phpMyAdmin.

Deleting tables in a MySQL database with phpMyAdmin.

Inserting fields into a MySQL database table using phpMyAdmin.

Modifying fields in a MySQL database table using phpMyAdmin.

Deleting fields in a MySQL database table using phpMyAdmin.

Exporting MySQL databases and tables using phpMyAdmin.

Importing MySQL databases and tables using phpMyAdmin.

Running SQL queries on a MySQL database using phpMyAdmin.

Searching through a MySQL database using phpMyAdmin.

2

Page 3: MySQL Database with  phpMyAdmin

Part 1: familiarizing yourself with

phpMyAdmin

By: Msc. Karwan M. Kareem2014 - 2015

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015 3

Page 4: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

This lecture assumes that you have already logged in to phpMyAdmin.Now let’s familiarize ourselves with MySQL database and phpMyAdmin.

4

Page 5: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

From this phpMyAdmin screen, we have access directly to database demo123_members listed her.

5

Page 6: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

This particular database has two tables called details and information, and they are listed her.

6

Page 7: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

This particular database has two tables called details and information, and they are listed her.

7

Page 8: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

To show all tables click the database name.From here we can see more information about the tables contained in the database as well as perform several actions.

1

2

8

Page 9: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

Browse: we can Browse a table to see the individual records

9

Page 10: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

Structure: we can see the Structure of a table and perform certain actions.

10

Page 11: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

Search: we can Search through a table for specific keywords

11

Page 12: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

Insert: we can insert new rows (or field) into a table.

12

Page 13: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

Empty: we can Delete the contents of a table.

13

Page 14: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

Drop: we can Delete (or drop) an entire table altogether.

14

Page 15: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

We can alternatively click on this link to view the database Structure

15

Page 16: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

SQL Query Window: we can open a SQL Query window for entering direct queries to the database.

16

Page 17: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

We can click on this link to perform Search.

17

Page 18: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

This also opens a SQL Query window, but provides an easier step-by-step way to make queries.

18

Page 19: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

Export: we can Export databases to our local computer.

19

Page 20: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

Import: we can import previously exported databases from local computer into MySQL server..

20

Page 21: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

Operations: we can do a number of other operations like creating new tables copying or renaming databases from here.

21

Page 22: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

Now let’s look at the structure of the details table.The structure of the details table lists all the table’s fields, along with the type of fields etc…

1

2

22

Page 23: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

Indexes: here it tell us that the id field is the primary key field.

23

Page 24: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

Documentation: if you want further help with SQL you can click documentation icon...

24

Page 25: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

Clicking here is another way of opening the SQL query window.

25

Page 26: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

Logout: clicking here logs you out phpMyAdmin.

26

Page 27: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Familiarizing yourself with phpMyAdmin

Let’s return to the main screen by clicking on home icon. you should now be more familiar with phpMyAdmin, and what you can use it to do.

1

2

27

Page 28: MySQL Database with  phpMyAdmin

Part 2: Creating tables in a MySQL database

with phpMyAdmin

By: Msc. Karwan M. Kareem2014 - 2015

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015 28

Page 29: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Creating tables in a MySQL database with phpMyAdmin

Now let’s learn how to create a table within a database. Select the demo1234_members database here.

1

2

29

Page 30: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Enter a Name for our new table. Then enter the number of fields this new table is to have.

1

2

Creating tables in a MySQL database with phpMyAdmin

30

Page 31: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

After entering the number of fields, click go.Now enter the details of each fields within the new table.

1

2

Creating tables in a MySQL database with phpMyAdmin

31

Page 32: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

The first field will be called id and it will be an integer that’s 4 charactersin length.We also want this first field to be the primary key that will beautomatically filled in (auto_increment) when new entries are added tothe table.

Creating tables in a MySQL database with phpMyAdmin

32

Page 33: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Selecting this option makes the id field the primary key in the table.

Creating tables in a MySQL database with phpMyAdmin

33

Page 34: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

The remaining fields will be CHAR (character) fields. Be sure the length isset long enough to accommodate the fields.When finished click Save.

Creating tables in a MySQL database with phpMyAdmin

34

Page 35: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

That’s it!! Our new table (details) has been successfully created withinour database (demo1234_members) as indicated here.

Creating tables in a MySQL database with phpMyAdmin

35

Page 36: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

This is the end of the part 2. You now know how to create new tableswithin a database using phpMyAdmin.

Creating tables in a MySQL database with phpMyAdmin

36

Page 37: MySQL Database with  phpMyAdmin

Part 3: Deleting tables in a MySQL database

with phpMyAdmin

By: Msc. Karwan M. Kareem2014 - 2015

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015 37

Page 38: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Now let’s learn how to delete a table from a database.Select the table you wish to delete here.

Deleting tables in MySQL database with phpMyAdmin

38

Page 39: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

However in this part we’re going to demonstrate how delete the entiretable and everything in it. You can delete individual fields from this tableby selecting them here. then clicking the delete icon here.

Deleting tables in MySQL database with phpMyAdmin

1

2

39

Page 40: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

To delete the table click the Drop button here. Then click OK to confirm.

Deleting tables in MySQL database with phpMyAdmin

1

2

40

Page 41: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

This addresses table has been deleted (or dropped) from the database. second screen shows that the addresses table is no longer listed in ourdatabases list of tables.

Deleting tables in MySQL database with phpMyAdmin

1

2

1

2

41

Page 42: MySQL Database with  phpMyAdmin

Part 4: Inserting fields into a MySQL database table

using phpMyAdmin

By: Msc. Karwan M. Kareem2014 - 2015

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015 42

Page 43: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Now let’s learn how to insert fields into database tables. Select the details table here.In this case, let’s choose to add an address field AFTER the name field.

Inserting fields into a MySQL database table using phpMyAdmin

1

2

43

Page 44: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Choose the field (name) and click on the GO.

Inserting fields into a MySQL database table using phpMyAdmin

44

Page 45: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Fill all textboxes and click on finish when finished.That’s it!! Our details table now has a new address field.

Inserting fields into a MySQL database table using phpMyAdmin

1

2

45

Page 46: MySQL Database with  phpMyAdmin

Part 5: Modifying fields in a MySQL database table

using phpMyAdmin

By: Msc. Karwan M. Kareem2014 - 2015

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015 46

Page 47: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Now let’s learn how to modify fields in database table.Select the table (details) here, and let’s modify the address field.Click the change icon.

Modifying fields in a MySQL database table using phpMyAdmin

1

2

47

Page 48: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Make the changes you want then click Save.

Modifying fields in a MySQL database table using phpMyAdmin

1

2

48

Page 49: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

That’s it!! We’ve successfully changed the name of the address field tocity.You now know how to modify fields in a table using phpMyAdmin.

Modifying fields in a MySQL database table using phpMyAdmin

49

Page 50: MySQL Database with  phpMyAdmin

Part 6: Deleting fields in a MySQL database table

using phpMyAdmin

By: Msc. Karwan M. Kareem2014 - 2015

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015 50

Page 51: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

now let’s learn how to delete fields from database table, firstly selectthe details table here.Let’s delete the city field.

Deleting fields in a MySQL database table using phpMyAdmin

51

Page 52: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Select the city field, and click the Delete (or Drop) icon.Click Yes to confirm.

1

2

Deleting fields in a MySQL database table using phpMyAdmin

52

Page 53: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

That’s it!! We’ve successfully deleted the city field from our databasetable.You now know how to delete fields in a table using phpMyAdmin.

Deleting fields in a MySQL database table using phpMyAdmin

53

Page 54: MySQL Database with  phpMyAdmin

Part 7: Exporting and importing MySQL databases

and tables using phpMyAdmin

By: Msc. Karwan M. Kareem2014 - 2015

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015 54

Page 55: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Now let’s learn how to exporting MySQL databases.Click the database you wish to export here.Then click the Export button.

Exporting and importing MySQL database using phpMyAdmin

55

Page 56: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

In this case, we want to export the entire database in SQL format so wecan easily import it later. This is a good way to backup your database.Be sure to check any option you want before proceeding.

Exporting and importing MySQL database using phpMyAdmin

1

2

56

Page 57: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Check the save as file checkbox then click Go ok that’s it!! The demo1234_member has been exported to our localcomputer.

Exporting and importing MySQL database using phpMyAdmin

1

2

57

Page 58: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Now let’s import the saved copy of our database, which includes thedetails table. Browse the saved copy of our database (SQL file) and click GO.

Exporting and importing MySQL database using phpMyAdmin

1

22

58

Page 59: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

That’s it!! The demo1234_members database has been successfullyimported as indicated here. Lets go take a look.

Exporting and importing MySQL database using phpMyAdmin

1

22 2

59

Page 60: MySQL Database with  phpMyAdmin

Part 8: Running SQL queries on a MySQL database

using phpMyAdmin

By: Msc. Karwan M. Kareem2014 - 2015

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015 60

Page 61: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Now let’s learn how to run SQL Queries on a database.Click the database table you wish to run a SQL query on.Click the SQL button to SQL query window.

Running SQL queries on a MySQL database using phpMyAdmin

1

2

61

Page 62: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

In this part however, let’s demonstrate how to delete this address fieldusing pure SQL command.Then type the SQL command to delete the address field from the detailstable. Click Go when finished.

Running SQL queries on a MySQL database using phpMyAdmin

62

Page 63: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Click OK to Drop address field from the table.That’s it!! The SQL command has been executed. Let’s go take look.

Running SQL queries on a MySQL database using phpMyAdmin

2

1

63

Page 64: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

The address field is no longer in our details table.We now know how to use SQL Query window to SQL syntaxes.

Running SQL queries on a MySQL database using phpMyAdmin

Note: for more information on learning about SQL query syntax,visit the MySQL documentation by clicking on SQL icon..

64

Page 65: MySQL Database with  phpMyAdmin

Part 9: Searching through a MySQL database

using phpMyAdmin

By: Msc. Karwan M. Kareem2014 - 2015

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015 65

Page 66: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Now let’s learn how to use the Search feature.Click the database you wish to search here. Then click the Search button.Enter words or values to search for in the database.

Searching through a MySQL database using phpMyAdmin

66

Page 67: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

There are several options you can use to refine your search.

Searching through a MySQL database using phpMyAdmin

Note: this database only has one table (details), but if there weremore, you could limit your search to specific table here..

67

Page 68: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

When ready, click Go to perform the search.The search found one match.

Searching through a MySQL database using phpMyAdmin

1

2

68

Page 69: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

Click Browse link to look the result.We can now make changes, delete, export and print to the record thatwas found .

Searching through a MySQL database using phpMyAdmin

2

1

69

Page 70: MySQL Database with  phpMyAdmin

© University of Sulaimani, Faculty of Physical & Basic Education, Department of Computer Science 2014 / 2015

END…

END…Any questions..?

Hope you have been happyThank you

By: Msc. Karwan M. Kareem2014 - 2015

70


Recommended