Git Product home page Git Product logo

databases's Introduction

If you are following the HackYourFuture curriculum we recommend you to start with module 1: HTML/CSS/GIT. To get a complete overview of the HackYourFuture curriculum first, click here.

Please help us improve and share your feedback! If you find better tutorials or links, please share them by opening a pull request.

Module #6 - Databases: Store and retrieve data with MySQL (Backend)

Databases

Have you ever thought about how your brain remembers things? It happens automatically for humans, but that's not so for computers. Any time you go to a website and you fill in some details, in for example a form, that information needs to be saved somewhere. This "somewhere" is called a database.

In this module you'll learn all about a fundamental part of any software application: how to (safely) store data, so that it can be used on-demand. You'll learn how to structure and group data so your apps know where to find and store the correct data.

Learning goals

In this module you will get familiar with the complexity of storing data. By the end of it you have learned:

  • What the meaning is of a database entity
  • How to work with Structured Query Language (SQL)
  • Learn all about the relational model
  • Recognize the basic setup of a database
  • Know about MySQL as an example of a relational database system
  • Learn about NoSQL databases, with an emphasis on MongoDB

Before you start

Before you start you need to install the necessary software: MySQL.

Installation on Windows machine

Download the MySQL Community Server

Installation on Linux (Ubuntu)

MySQL Installation on Linux (Ubuntu) if you are using Ubuntu Linux.

Installation on MAC

Open the Terminal to type following commands.

  1. Install Homebrew if you don't have it:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  1. Install MySQL server and client using brew install mysql.

After you've finished installing the software, open it through your command line interface:

  • Windows users should use Microsoft MySQL Command Line client.
  • Linux users should use Gnome Terminal
  • MacOS users should use Terminal.

Step 1: Logging in with the root user

To get started with your new MySQL client, we first have to login with the root user.

A root user, also known as a superuser is a special user account that has access to all commands and files of any particular software.

In Windows OS, if you click on the Start menu and type MySQL Command line Client, then the MySQL Command Line Client gives you a msql> prompt after typing in your root password. Note that this password is the one you used for the root user of the mysql during the installation. Linux and MAC users can execute mysql -uroot -p and then type your root password.

Step 2: Creating a hyfuser account

After loggin in with the root user, it's time to create the account we'll be using for this module. Execute the following commands, one after the other:

# Step 1: This command creates a user 'hyfuser' with password 'hyfpassword' for the database server at 'localhost'

mysql> create user 'hyfuser'@'localhost' identified with mysql_native_password by 'hyfpassword';

# If this does not work try the alternative command:

mysql> create user 'hyfuser'@'localhost' identified by 'hyfpassword';

# Step 2: This command gives all permissions to user 'hyfuser'. The (*.*) means every table of every database.

mysql> grant all privileges on *.* to 'hyfuser'@'localhost';

# Step 3: This command creates a database named 'userdb'

mysql> create database userdb;

Step 3: Installing MySQL drivers for node

We want to use MySQL with JavaScript and to this end, we use mysqljs driver.

  • Use npm install -g mysql command to install them.
  • Run node connection-test.js by navigating to the Week1 folder from the VScode terminal.

The output should be The solution is: 2.

Planning

Week Topic Readings Homework Lesson Plan
1. What's a database, Entities, Data structures, Structured Query Language (SQL) Readings W1 Homework W1 Lesson Plan W1
2. Identifiers, Relationships, Domain Modeling, Advanced SQL commands Readings W2 Homework W2 Lesson Plan W2
3. Normalization, Transactions, SQL Injection, NoSQL (with MongoDB) Readings W3 Homework W3 Lesson Plan W3

Finished?

Did you finish the module? You're almost at the top!

If you feel ready for the next challenge, click here to go to React!

The HackYourFuture curriculum is subject to CC BY copyright. This means you can freely use our materials, but just make sure to give us credit for it :)

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.

databases's People

Contributors

allhandsondeck avatar chris-gunawardena avatar daanaerts avatar danlaudk avatar filievski avatar gajduk avatar gijscor avatar hatemkhattab avatar jasongwartz avatar jidarwish avatar laurensrietveld avatar mkruijt avatar noergitkat avatar old-profile avatar pcelentano avatar remarcmij avatar rts-rob avatar shadoo77 avatar tjebbee avatar tkaria avatar unmeshvrije avatar wilgert avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.