Introduction To Relational Database (RDBMS) - MySQL
This document provides an introduction to relational database management systems (RDBMS) using MySQL. It defines key database concepts like tables, columns, rows, primary keys and foreign keys. It then describes how to install MySQL using XAMPP, and provides steps to create a sample database called "firstdb" and table called "users" through SQL statements in the MySQL shell terminal. Sample data is inserted into the users table and selected to confirm the values were added successfully.
Introduction To Relational Database (RDBMS) - MySQL
This document provides an introduction to relational database management systems (RDBMS) using MySQL. It defines key database concepts like tables, columns, rows, primary keys and foreign keys. It then describes how to install MySQL using XAMPP, and provides steps to create a sample database called "firstdb" and table called "users" through SQL statements in the MySQL shell terminal. Sample data is inserted into the users table and selected to confirm the values were added successfully.
INTRODUCTION TO RELATIONAL PHP programming knowledge
DATABASE (RDBMS) WITH MYSQL required Prepared by: Eric Ijakaa Email: ericijakaa4@gmail.com DATABASE DEFINITION ❑A database is a standalone program used to store a set of data. For creating, accessing, managing, searching, and duplicating the data it holds, each database has one or more unique APIs. ❑Relational database management systems (RDBMS) are used today to store and manage massive amounts of data. Because all the data is stored in several tables and relationships are created using primary keys or other keys known as foreign keys, this is known as a relational database. FEATURES OF RDBMS ❑Permits the creation of a database containing tables, columns, and indexes. ❑Ensures that the referential integrity of rows across distinct tables is maintained. ❑Automates the updating of the indexes. ❑Interprets a SQL Query and aggregates information from several tables. TERMS USED IN RDBMS Let's update a few definitions relating to the database before we continue with our explanation of the MySQL database system. A database is a group of tables that contain connected data. ❑Table: A table is a data matrix. A table in a database resembles a straightforward spreadsheet. ❑Column: One column (data element) includes data of one type only, such as the postcode column. ❑A row, also known as a tuple, entry, or record, is a collection of connected data. the information from one subscription, for instance. ❑Redundancy is the practice of redundantly storing data to speed up a system. ❑A primary key is a key that is distinct. In a single table, a key value cannot appear twice. Only one row can be located using a key. CONT’D ❑Compound Key: A compound key (composite key) is a key that consists of multiple columns, because one column is not sufficiently unique. ❑Index: An index in a database resembles an index at the back of a book. ❑Referential Integrity: Referential Integrity ensures that a value for a foreign key always refers to a row that already exists. ❑A foreign key serves as the connecting thread between two tables. MYSQL DATABASE What can MySQL database achieve? ❑An open-source license governs the distribution of MySQL. So you have nothing to pay to use it. By itself, MySQL is a pretty potent program. It manages a sizable portion of the most pricey and potent database packages' features. ❑A standardized version of the well-known SQL data language is used by MySQL. ❑MySQL runs on various operating systems and with numerous languages including PHP, PERL, C, C++, JAVA, etc. ❑Even with large data sets, MySQL operates quickly and effectively. ❑MySQL is particularly friendly to PHP, the most respected language for web development. ❑MySQL can handle very large databases. ❑MySQL can be customized. The MySQL software can be altered by programmers to fit their particular environments thanks to the open-source GPL license. INSTALLING MYSQLI ❑There various ways of installing MySQL depending with the kind of Operating System on your PC. ❑In this tutorial we are going to use the most efficient way with know errors of installing MySQL. ❑We will use the XAMPP application to run a local server which comes with MySQL Server. INSTALLATION ❑Open in your browser https://www.apachefriends.org/download.html and download the latest XAMPP application executable file. ❑XAMPP is an easy to install Apache distribution containing MariaDB, PHP, and Perl. Just download and start the installer. It's that easy. WINDOWS MAC LINUX INSTALLING CONT’D After installation and upon launch, you are required to click on the “Start” on both Apache and MySQL servers. If you need to shut down the server you will click on “Stop” SUCCESSFUL INSTALLATION READY TO MYSQLI With Xampp you can use the browser to create the database by clicking this link http://localhost/phpmyadmin/ where by one can create the database from the GUI interface. There is also the shell terminal that helps the user also to create the database. Shell terminal being somehow challenging for beginners we go step by step so that you are not left behind. If you’ll problems using shell terminal, I recommend using the first option of using the browser interface. MYSQL SHELL TERMNAL We have launched the shell terminal and ready to start using some statements to proceed USING TERMINAL Use the script to launch MySQL on the terminal # mysql -u root –p We are using default user with no password. The outcome is shown below CREATING THE DATABASE MariaDB [(none)]> CREATE DATABASE `firstdb`; Query OK, 1 row affected (0.049 sec) The query was successful and the database named “firstdb” is created. Let’s check if the database exists MariaDB [(none)]> SHOW DATABASES; DATABASE CREATED SUCCESSFULLY The database was successfully created as we can see it exists among the databases with the server. CREATING TABLES First let’s check if the database has any table. Syntax of creating table: CREATE TABLE IF NOT EXISTS `users`( `userid` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `username` TEXT NOT NULL , `email` VARCHAR(55) NOT NULL , `password` VARCHAR(55) NOT NULL ); The table was successfully created. We need to insert data into the table using the SQL Statement Query INSERT Statement: INSERT INTO `users` (`userid`, `use rname`, `email`, `password`) VALUES (NULL, 'user1', 'ericijakaa4@gmail .com', '1234’); We did not include the value for userid hence because we specified an autoincrement function during table creation which means the values for userid will be inserted automatically. VIEW TABLE DATA To check the values in a table we use the following SQL Statement. SELECT * FROM `users`;