Module - P7 Lecture - 15 Practical: Interacting with a DBMS

Similar documents
Module - 17 Lecture - 23 SQL and NoSQL systems. (Refer Slide Time: 00:04)

CMS and e-commerce Solutions. version 1.0. Please, visit us at: or contact directly by

DATABASE SYSTEMS. Database programming in a web environment. Database System Course, 2016

Privacy and Security in Online Social Networks Department of Computer Science and Engineering Indian Institute of Technology, Madras

sqlite wordpress 06C6817F2E58AF4319AB84EE Sqlite Wordpress 1 / 6

Privacy and Security in Online Social Networks Department of Computer Science and Engineering Indian Institute of Technology, Madras

DATABASE SYSTEMS. Introduction to MySQL. Database System Course, 2016

DATABASES SQL INFOTEK SOLUTIONS TEAM

Serverless Single Page Web Apps, Part Four. CSCI 5828: Foundations of Software Engineering Lecture 24 11/10/2016

Programming, Data Structures and Algorithms Prof. Hema A Murthy Department of Computer Science and Engineering Indian Institute of Technology, Madras

Fundamentals of Operations Research. Prof. G. Srinivasan. Department of Management Studies. Indian Institute of Technology Madras.

Chapter 3. Introduction to relational databases and MySQL. 2010, Mike Murach & Associates, Inc. Murach's PHP and MySQL, C3

Zello Quick Start Guide for Kyocera TORQUE

DATABASE SYSTEMS. Database programming in a web environment. Database System Course,

Locate your Advanced Tools and Applications

The connection has timed out

DATABASE SYSTEMS. Introduction to MySQL. Database System Course, 2016

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

A Simple Course Management Website

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Introduction to relational databases and MySQL

Connecting to the Virtual Desktop Infrastructure (VDI)

Advanced Operations Research Prof. G. Srinivasan Department of Management Studies Indian Institute of Technology, Madras

style type="text/css".wpb_animate_when_almost_visible { opacity: 1; }/style

Bitnami MEAN for Huawei Enterprise Cloud

Mobile Login extension User Manual

Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

The English School Network

Kendo UI. Builder by Progress : Using Kendo UI Designer

RECEIPT BANK SUBMISSION METHODS: EFFORTLESS!

GETTING STARTED GUIDE

Announcements. PS 3 is out (see the usual place on the course web) Be sure to read my notes carefully Also read. Take a break around 10:15am

Rain Bird Knowledge Center Troubleshooting Guide

Introduction to Operations Research Prof. G. Srinivasan Department of Management Studies Indian Institute of Technology, Madras

Setting Up A WordPress Blog

3344 Database Lab. 1. Overview. 2. Lab Requirements. In this lab, you will:

Live Guide Co-browsing

Advanced Operations Research Prof. G. Srinivasan Department of Management Studies Indian Institute of Technology, Madras

Install and make Apache + PHP to work with PosgreSQL database server on Debian Linux and set up server Web Posgre interface Pgpadmin howto

Quick Guide to Installing and Setting Up MySQL Workbench

Windows Backup Server Installation

Installing Oxwall completely in Amazon Cloud

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

APPVISIBILITY COLLECTOR SERVER

Tutorial: Using Java/JSP to Write a Web API

ITCorporation HOW TO DOWNLOAD, INSTALL AND SET UP SONICWALL ANALYZER DESCRIPTION RESOLUTION. Knowledge Database KNOWLEDGE DATABASE

The MANUAL. 1 P a g e

Webomania Solutions Pvt. Ltd. 2017

Port Forwarding Setup (RTA1025W)

Installation User Guide SMART ACCESS 2.0

High Performance Computer Architecture Prof. Ajit Pal Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

SynwaySMS SMS Center. User Manual

XenMobile 10 Cluster installation. Here is the task that would be completed in order to implement a XenMobile 10 Cluster.

High Performance Computer Architecture Prof. Ajit Pal Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Advanced Database Project: Document Stores and MongoDB

Using Relational Databases for Digital Research

Unified Communicator User Guide. Version 2.4

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

web.py Tutorial Tom Kelliher, CS 317 This tutorial is the tutorial from the web.py web site, with a few revisions for our local environment.

CGS 3066: Spring 2017 SQL Reference

Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting

System Admin Manual <SNAPVALET> <Team No- 03>

Android Mobile-App Instructions

Easy Worklog for JIRA. User Manual

DIGITA PRACTICE ADVANCED MOBILE. Getting Started. version 1.0.x. Digita Support: Digita Sales: digita.

Setting up the Master Computer

VAR OUT-OF-THE-BOX STORE

Development Technologies. Agenda: phpmyadmin 2/20/2016. phpmyadmin MySQLi. Before you can put your data into a table, that table should exist.

PostgreSQL Installation Guide

Welcome to Database Exporter for SharePoint

Perl Dbi Last Insert Id Example >>>CLICK HERE<<<

CONTROL Installation and Basic-configuration Guide Contents

Login Troubleshooting

The PHP language. Teaching you everything about PHP? Not exactly Goal: teach you how to interact with a database via web

IELM 511 Information Systems Design Labs 5 and 6. DB creation and Population

Mysql Tutorial Create Database Username Password Through Phpmyadmin

McAfee Database Security Hotfix 2 Release Notes

Client Side Scripting. The Bookshop

COS 333: Advanced Programming Techniques. Copyright 2017 by Robert M. Dondero, Ph.D. Princeton University

Database Systems. Sven Helmer. Database Systems p. 1/567

Release Notes. Lavastorm Analytics Engine 6.1.3

Extensions. Server-Side Web Languages. Uta Priss School of Computing Napier University, Edinburgh, UK. Libraries Databases Graphics

Fundamentals of Operations Research. Prof. G. Srinivasan. Department of Management Studies. Indian Institute of Technology, Madras. Lecture No.

Real Application Security Administration

Kaltura App Things to Remember... 3 Downloading the App My Media... 4

1 Setting Up Your Auto Login Link in Windows

Contents. Introduction To CloudSync. 2. System Requirements...2. Installing CloudSync 2. Getting Started 4

CSCI 201 Lab #11 Prof. Jeffrey Miller 1/23. Lab #11 CSCI 201. Title MySQL Installation. Lecture Topics Emphasized Databases

Stored procedures - what is it?

ULTEO OPEN VIRTUAL DESKTOP DEBIAN WHEEZY (7.0) SUPPORT

Bitnami ProcessMaker Community Edition for Huawei Enterprise Cloud

Privacy and Security in Online Social Networks Department of Computer Science and Engineering Indian Institute of Technology, Madras

Avaya Desktop Collector Snap-in R GA Release Notes

A practical introduction to database design

Create-A-Page Design Documentation

CMS and e-commerce Solutions. version 1.0. Please, visit us at: or contact directly by

Lab 2: Setting up secure access

How to Connect to the CSH Virtual Desktop

Administration Manual

Princess Nourah bint Abdulrahman University. Computer Sciences Department

Transcription:

Introduction to Modern Application Development Prof. Tanmai Gopal Department of Computer Science and Engineering Indian Institute of Technology, Madras Module - P7 Lecture - 15 Practical: Interacting with a DBMS Hi all. Welcome to Module - P7. And this module, we will be doing some basic Interactions with DBMS. (Refer Slide Time: 00:07) We will be using the DBMS via a typical management console or web base management console. In this case, the console is called Adminer, but similar consoles are PHP my admin for MySQL and say RockMongo for MongoDB. If we are going to create a few tables and run a few create, read, update, delete are also known as CRUD. And we are going to run some CRUD operations we are the DBMS on the on our database.

(Refer Slide Time: 00:30) Quickly recap what we have learnt so far. We have learnt that we need to separate code and data in our applications. We also need we have also learnt that we need a convenient way of reading writing, writing to and storing persistent data into what we call a database. And applications that allow us to do this easily are called DBMSs. (Refer Slide Time: 00:49) So, we are going to login our database via a web. And we have the management console app which is called Adminer. We are going to create the tables that model the user and

the articles from the last module. And then we are going to run some common operation on our data. (Refer Slide Time: 01:02) To generate your database credential head to the cloud.imad.hasura.io console. (Refer Slide Time: 01:08) So I click on create database credentials.

(Refer Slide Time: 01:13) And I get the credentials to access my database. (Refer Slide Time: 01:20) To head to the database console, click on this link. I have to copy my credentials here. Let us get the username, and let us get the password. The database that you have login into is the same as the username. So, we enter that as well I say I want to stay logged in and I click on login. I save the password.

(Refer Slide Time: 01:46) Now you can see that we have access to our database. So, we already have a database and a database is called my case coco98. (Refer Slide Time: 01:59) Let us create a new table. Let us start of by creating a user table, so table name is called user. The first column is an id and I let the id be an integer. Most databases especially relational databases have an option of making a column auto incrementing; and auto incrementing means that the value of id will keep increasing whenever a new row is inserted.

So, you will see and how that works in a bit. And then I have a user name which would be a text column, I will have a name; it should be also a text column. And I can add email also a text column I so let saved this. (Refer Slide Time: 02:42) Now, let us create, so we can see that the structure of the table is that there is an id, username, name and email, these are the columns and you can see the types of the columns. Let us add a primary key and a primary key will allow us to identify a particular row in this table uniquely. Now people might have usernames that are the same or the names that are the same; and people might even have similar emails, but I want the id to be unique, so because the id is unique will create a primary key on the id column.

(Refer Slide Time: 03:08) So I add an index and I say index type is primary, I set the column to id, and I will save it. (Refer Slide Time: 03:15) Now I have a primary key you can see that the indexes list, there is an index called primary key which is the id column.

(Refer Slide Time: 03:24) Let us try to insert some data. I won t insert anything in the id type; and because the by default, it will increase automatically. And I will set the username to coco98 and I save this. (Refer Slide Time: 03:45) You can see that a row has been added and the id is set to 1 automatically.

(Refer Slide Time: 03:51) Let us create a new item and let say user 2; user2@user2.com and save this. (Refer Slide Time: 03:59) Once you save this, you will see if the id is automatically set to 2. So this is because it is auto incrementing. So we added two rows in this.

(Refer Slide Time: 04:10) Now let us create a new table called the article table. So, I go back here and click on create table, and the create table called the article table. And let say id which is again auto incrementing. Let us set the title of the article, which is a text. And content of the article which is again text. Let us say that the article is an author, which will use the id which is an integer type. This is the author of the article and they should ideally come from the user table. Let us save this. (Refer Slide Time: 04:49)

Let us make id the primary key of this table too. So, now we have these 4 columns and the primary key set to id. (Refer Slide Time: 04:54) Let us insert some values. So, I go and check id for the article, let say this is article 1, this is my first article. And let say the authors' id is 1, and I save this. (Refer Slide Time: 05:07) So, I have element in the article table; I have a row in the article table.

(Refer Slide Time: 05:16) And, so let us insert another article, this is also called article 1. And this is my first article by a different user, and let say this author id is 99. And I save it. (Refer Slide Time: 05:26) So, I have two articles and I have two users right, but obviously, the problem is that I have an article and this articles author does not actually exist in the author table. So, the author, there are only two authors 1 and 2, but there is no author for there is no author called 99. And so how do we ensure that we can actually constrain these two values that

are in the author that are in the user table, so the way to do that is to create something called a foreign key constraint. (Refer Slide Time: 06:05) Let us create a foreign key constraint so that the author id is always a value from the users id call. So go to the show structure, you see a heading called foreign keys. Click on add foreign key. (Refer Slide Time: 06:09) Set the target table to the user table. You can set that the source as the author id and the target is id. And you can click on save. So as soon this happen, you can see that we got

an error. And now let us read this error right. So, this error says that key author id equal to 99 is not present in table user, because we already have inconsistent data; we are not able to add the foreign key. (Refer Slide Time: 06:33) Let us go and remove that inconsistent element. So, I select that element and I click on delete right and that row is gone. Let us try to add the foreign key again; my author id is the user id, you can save. (Refer Slide Time: And you can see this, the foreign key is been created.

(Refer Slide Time: 06:51) Now if you try to insert another article, and insert a random author id, let say 99. And you try to save it, you will get an error. And the error says insert or update on table article violates the foreign key constraint, article author id foreign key, which is the name of the constraint that the database is given to your foreign key constraint. If you change this to something that exist like two, and save it, the saving goes through. So, this is our basic modeling done. (Refer Slide Time: 07:27)

Let us try to understand how all of got we did works. So when we went into the IMAD console and clicked on clicked on the buttons that are generate DB credentials, what actually happened is that there was a database or DBMS that was sitting on the db.imad.hassuraapp.io server. And on this machine there was a Postgres DBMS; the IMAD console contacting this DBMS, and run operations to create the username, the password and the database. Once these are successfully created, this data was taken aback by the IMAD console and display to us on the UI. (Refer Slide Time: 07:59) Once we went to the link db.imad.hassuraapp.io, which is the link that we got when we clicked on generating credentials, our browser opened up another web app and this is the Adminer web app which was which is PHP web app and this is what I call the DBMS console which can also be say PHP my Adminer or RockMongo. And when we logged into the DBMS and when we create a tables, when we create a rows, whenever we did these things what was happening was that we will giving commands to the web app, we have the UI and by clicking on buttons and by entering data, and the web app was actually taking the information and running commands on the DBMS. So, we are not actually running commands directly on the Postgres DBMS, we were running commands on the Adminer web app, and this was taken and executed on the DBMS. So this is this is what was really happening right; and the Adminer web app or the PHP web app and the Postgres DBMS who are all about sitting together on the

db.imad.hassuraapp.io machine. So, on this machine, we have two servers now the web server which listens to our commands and the DBMS server. (Refer Slide Time: 09:08) You can also run this entire system locally by installing the Postgres DBMS on your system and by installing Adminer, which is the DBMS console on your system. There are various installation guides; I have provided links of the official guides for installing on windows, Mac and Linux. You will also then have to install Adminer; Adminer is a very simple PHP application. So to install Adminer or a rather to run Adminer, you will need to install PHP and apache on your system. Just Google for how to install apache and PHP on Windows or Linux or Mac, and you will find several useful guides to getting this running on your system.

(Refer Slide Time: 09:43) A few important topics that which we just briefly touched upon about which we will get into more detail later are primary keys, Nullable columns and default values for columns. So, we go into more detail about each of these things in the next module. (Refer Slide Time: 09:56) In the next module, we are going to add categories and tags and then we are going to look at what SQL is. After that we are going to connect our application to the database that we have made. And we are going to fetch our article data of our web app from this database.