top of page
Writer's pictureNerdZone

Create your friend's Database using MySQL

“Information storage is the oil refinery for the 21st century.” The answer to how to store information is Databases. Introducing databases to kids will open up a new path to them and exploring it will enable them to grasp more computational and complex problems and creations. This experiment will teach the kids to create, add, delete and drop the information from the relational database. Many times we write the information on a piece of paper and then lose it. Creating a personal database on your laptop will never let you lose information. In this project, create a friend's database using MySQL.





Introduction:


Any data that is stored permanently outside of an application is stored in a database-like file. The information in these files may be broken down into records, each of which consists of one or more fields. SQL is an abbreviation of Structured Query Language. SQL is the standard means of manipulating and querying data in relational databases.


Requirements:


Download MySQL using the below page


Follow instructions shown for MAC OS -


While configuring the setup, you can select the option of a legacy encryption password to avoid any issue.


Steps:


Use system preferences to:

  • open the MySQL settings to start and stop the server.

  • open MySQLWorkBench and select the required connection.


  • Open query window to write queries to do the project.


Writing Queries

Create a database and use the database.

-- create a database
create database my_friends_db;

-- use database
use my_friends_db;

In that database, initially create a table with three columns or rather fields.
create table my_best_friends(
name varchar(255),
age int,
gender varchar(10),
email varchar(100)
);

Insert the first few records in your table first.
insert into my_best_friends values("Max",12, "male", "max@abc.com");
insert into my_best_friends values("Stella",15, "female", "stella@abc.com");
insert into my_best_friends values("Rose",11, "female", "rose@abc.com");
insert into my_best_friends values("Mike",12, "male", "mike@abc.com");

View the entire table and then view a particular column from a table
-- fetch all records
select * from my_best_friends;

-- fetch  records with where clause
select * from my_best_friends where age=12;

Delete a record from the table then delete or rather drop the table/database created
-- drop database
drop database my_SQL_project;

-- delete record
delete from my_best_friends where name ='Max';

Download the sample.sql file from here for reference.





Learning Opportunity:

  • In SQL, data is organized in tables, for e.g. ‘my_friends_db’ database may have tables best_friends and sports_teams

  • SQL is a standard language for storing, manipulating and retrieving data in databases


Time Required: 30 minutes


Cost: NIL


125 views0 comments

Recent Posts

See All

Comentários


bottom of page