How to Create Database Library in PhpmyAdmin using SQL

in utopian-io •  7 years ago  (edited)

What Will I Learn?

  • how the database works
  • know how to create database using SQL
  • know how to create tables in a database using SQL

Requirements

  • Computers / Laptops
  • XAMPP Control panel v 3.2.2
  • Web browser

Difficulty

  • Intermediate

Tutorial Contents

In this tutorial I will explain how to create database using SQL in PhpMyAdmin on local computer
PhpMyAdmin is a web application for managing MySQL databases and MariaDB databases more easily through graphical interface. This web application is written using PHP programming language. As with other applications for the web environment (apps that are opened or run using a browser), phpMyAdmin also contains HTML / XHTML, CSS as well as JavaScript code. This web application is intended to facilitate the management of MySQL and MariaDB databases with the presentation of a complete and attractive web interface.

  • Turn on Xampp control panel and then click "Apache and Mysql" which is already installed.
    Screenshot_1.png

  • Then open Browser window, then type Localhost, then click phpMyadmin.
    Screenshot_2.png

  • After clicking PhpMyadmin, you will enter the PhpMyadmin page and look like this: ,then click SQL
    Screenshot_3.png

  • Then type in this code and click GO

create database dbLibrary;

Screenshot_4.png

  • Results from the code
    Screenshot_5.png

  • Now we will create a table to hold the data

create table tbMemberType(
    idMemberType smallint auto_increment not null primary key,
    MemberType varchar(25) not null unique,
    BorrowDaily smallint
)

Screenshot_6.png

-Results
Screenshot_7.png

  • Now you can add the script below to create an additional table for your database
create table tbMember(
    idMember char(3),
    Name varchar(50),
    idMemberType smallint,
    address varchar(50),
    gender enum('P','W'),
    dateofbirth date,
primary key(idMember),
foreign key(idMemberType) references tbMemberType(idMemberType)
on delete restrict on update cascade
)
create table tbauthor(
    idauthor smallint auto_increment not null primary key,
    Name varchar(25) not null, address varchar(25) not null,
    dateofbirth enum('P','W'), dateofbirth date 
)
create table tbcollectiontype(
    idcollectiontype smallint auto_increment not null primary key,
    collectiontype varchar(25) not null unique, oldloan smallint 
)
create table tbcollection(
    idcollection char(5), Judul varchar(50), idcollectiontype smallint not null,
    idauthor smallint not null, idpublisher smallint not null,
    information varchar(50), price int, FinePerDay int,
    primary key(idcollection),
    constraint refKolTipe foreign key(idcollectiontype) references
    tbcollectiontype(idcollectiontype) on delete restrict on update cascade,
    constraint refKolPengarang foreign key(idauthor) references
    tbauthor(idauthor) on delete restrict on update cascade,
    constraint refKolPenerbit foreign key(idpublisher) references
    tbpublisher(idpublisher) on delete restrict on update cascade
)
create table tbloan(
idloan smallint auto_increment not null, dateofborrowing date,
idcollection char(5) not null, idMember char(3) not null,
datemustbereturned date, returndate date, payafine int,
primary key(idborrow,dateofborrowing),
constraint refPinKol foreign key(idcollection) references tbcollection(idcollection)
on delete restrict on update cascade,
constraint refPinAnggota foreign key(idMember) references
tbMember(idMember)
on delete restrict on update cascade
)

Congratulations you have successfully created the database and tables for the database, now you can fill the table with the data you want. hopefully the tutorial that I post this time bermanfaaf for you all.

Thanks

Curriculum

Not yet, this is the first time



Posted on Utopian.io - Rewarding Open Source Contributors

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Your contribution cannot be approved because it does not follow the Utopian Rules.

My Opinion:

  • Too trivial.

You can contact us on Discord.
[utopian-moderator]

Hey @portugalcoin, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

Reading through the instructions on how to create a database library in PhpmyAdmin using SQL got me intrigued. Creating a functional database library seems like a smart move for any business looking to organize its data efficiently. The way the guy detailed his process is really helpful, especially the emphasis on database design. It's fascinating how a well-thought-out design can make all the difference in managing and retrieving information seamlessly. Plus, I totally agree that having a database software that caters to various business needs is a game-changer.