1. Create a database called "FTMS".
2. Create a table called "student" with fields for student ID, name, program, mode, date registered, and fee.
3. The table was created with the specified fields and data types to store student information in the new "FTMS" database.
2. Database
• A database is a separate application that stores a collection of
data.
• Each database has one or more distinct APIs for creating,
accessing, managing, searching and replicating the data it
holds.
• Other kinds of data stores can be used, such as files on the file
system or large hash tables in memory but data fetching and
writing would not be so fast and easy with those types of
systems.
3. Database Terminologies
• Database − A database is a collection of tables, with related
data.
• Table − A table is a matrix with data. A table in a database
looks like a simple spreadsheet.
• Column − One column (data element) contains data of one
and the same kind, for example the column postcode.
• Row − A row (= tuple, entry or record) is a group of related
data, for example the data of one subscription.
• Redundancy − Storing data twice, redundantly to make the
system faster.
• Primary Key − A primary key is unique. A key value can not
occur twice in one table. With a key, you can find at most one
row.
4. MySQLi
• MySQLi is a Relational SQL database management system.
• MySQLi is used inside the PHP programming language to give
an interface with MySQL databases.
5. MySQLi Database
• MySQLi is released under an open-source license.
• MySQLi is a very powerful program in its own right. It handles a large
subset of the functionality of the most expensive and powerful
database packages.
• MySQLi uses a standard form of the well-known SQL data language.
• MySQLi works on many operating systems and with many languages
including PHP, PERL, C, C++, JAVA, etc.
• MySQLi works very quickly and works well even with large data sets.
• MySQLi is very friendly to PHP, the most appreciated language for
web development.
• MySQLi supports large databases, up to 50 million rows or more in a
table. The default file size limit for a table is 4GB, but you can
increase this (if your operating system can handle it) to a theoretical
limit of 8 million terabytes (TB).
6. PHPMyAdmin
• phpMyAdmin is a free software tool written in PHP, intended
to handle the administration of MySQL over the Web.
• phpMyAdmin supports a wide range of operations on MySQL
and MariaDB.
• Frequently used operations (managing databases, tables,
columns, relations, indexes, users, permissions, etc) can be
performed via the user interface, while you still have the
ability to directly execute any SQL statement.
7. PHPMyAdmin cPanel
• On the right side of the screen, in the Database server section you
can find information about the MySQL server.
• The databases which you will manage are stored on the same server
as the software and the hostname is - localhost.
• In the middle part of the page, in the General Settings section, you
can see the MySQL charset and you will be able to define the MySQL
connection collation (utf8_general_ci is the most common utf8
collation).
8. PHPMyAdmin cPanel
• In the Databases tab you will find a list with all the databases
which can be managed through the cPanel user.
9. PHPMyAdmin cPanel
• Using SQL tab you can perform a MySQL query towards the
MySQL server. Just type in the query and click the Go button
and the phpMyAdmin tool will execute the query and provide
the results from it.
10. PHPMyAdmin Creating Database
• Click the Databases tab and then select a database to manage
by clicking its name.
• In the page that opens you will see a list with the database
tables, the allowed actions with them, the number of the
records, the storage engine, the collation, the tables' sizes and
the overhead
11. PHPMyAdmin Creating Database
Browse
• Only the tables with existing records can be browsed. Once
you click on the Browse button a new page with a list of the
records inside the table will be opened.
• By clicking on the Edit button you can edit the chosen record.
• You will see the record structure and you can alter the values
of the records. Once you are done with the changes, you can
submit them bu clicking the Go button at the bottom of the
page.
12. PHPMyAdmin Creating Database
Structure
• By clicking the Structure button a new page will open that
shows the database table's structure.
• You will see the fields' names, their types, collations,
attributes, additional extra information, the default values and
whether the fields' values can be NULL.
13. PHPMyAdmin Creating Database
Insert
• Using the Insert button you can insert records in your
database table.
• Once you fill in the corresponding values click on the Go
button and the new record will be inserted.
15. PHPMyAdmin Creating Table
• To create new tables inside a database, first open the
phpMyAdmin tool, click on the Databases tab and click on the
name of the desired database. On the new page that opens
you will see a list of all the current tables inside the database
and a section named Create table.
• In that section, in the Name field you should input the desired
new name of the table and then select the number of columns
that the table should have via the Number of columns drop-
down.
• When ready, click the Go button to create the table.
16. PHPMyAdmin Creating Table
• Name - The name of the column;
• Type - The type of the data, which will be stored in the
corresponding column. More details about the possible
choices can be found in the official MySQL Data Types
documentation;
• Length/Values - The length of the field;
Default - With this option you can specify if the fields in the
column would have a default value. This is useful for example
if you want to have timestamps for the entries in each row;
Collation - The data collation for each of the fields;
• Attributes - assign any special attributes to the fields;
17. PHPMyAdmin Creating Table
• Null - Define whether the field value can be NULL. More about
the NULL value can be found in the MySQL documentation;
• Index - Set the Index of the row. More information about the
MySQL column indexes can be found in the MySQL
documentation;
• A_I - Short for Auto Increment. If this option is enabled then
the values in the fields of the column will be auto
incremented;
• Comments - Here you can add comments, which will be
included in the database SQL code.
18. PHPMyAdmin Creating Table
To create a table:
• Select the database.
• Enter a Name for the new table.
• Enter the number of fields this new table is to have. Click Go.
• Enter the details of each field within the new table.
• Field Name, Data Type, etc…
19. PHPMyAdmin Data Types
• Properly defining the fields in a table is important to the
overall optimization of your database.
• You should use only the type and size of field you really need
to use.
• These types of fields (or columns) are also referred to as data
types, after the type of data you will be storing in those fields.
20. PHPMyAdmin Data Types
Numeric Data
Data Type Description
INT A normal-sized integer that can be
signed or unsigned. If signed, the
allowable range is from -2147483648 to
2147483647. If unsigned, the allowable
range is from 0 to 4294967295. You can
specify a width of up to 11 digits.
FLOAT(M,D) A floating-point number that cannot be
unsigned. You can define the display
length (M) and the number of decimals
(D).
21. PHPMyAdmin Data Types
Date and Time
Data Type Description
DATE A date in YYYY-MM-DD format, between
1000-01-01 and 9999-12-31.
TIME Stores the time in HH:MM:SS format.
YEAR(M) Stores a year in 2-digit or 4-digit format.
If the length is specified as 2 (for
example YEAR(2)), YEAR can be 1970 to
2069 (70 to 69).
22. PHPMyAdmin Data Types
String
Data Type Description
VARCHAR(M) A variable-length string between 1 and
255 characters in length; for example
VARCHAR(25). You must define a length
when creating a VARCHAR field.
CHAR(M) A fixed-length string between 1 and 255
characters in length (for example
CHAR(5)), right-padded with spaces to
the specified length when stored.
Defining a length is not required, but
the default is 1.
23. Lab Practical
1. Create a Database called “FTMS”
2. Create a Table called “student” with the following attributes:
Field Name Data Type
studentid int
studentname varchar
studentprogramme varchar
programmemode varchar
dateregister date
fee int