COP5725 DATABASE MANAGEMENT POSTGRESQL TUTORIAL

Slides:



Advertisements
Similar presentations
WaveMaker Visual AJAX Studio 4.0 Training
Advertisements

Microsoft SQL Server 2008 From the Program menu choose: Microsoft SQL Server 2008 R2  SQL Server Management Studio. You may see a window indicating the.
Results of the survey and relational dbs Fall 2011.
COMPREHENSIVE Access Tutorial 2 Building a Database and Defining Table Relationships.
Concepts of Database Management Sixth Edition
FIRST COURSE Access Tutorial 2 Building a Database and Defining Table Relationships.
COP4710 D ATABASE M ANAGEMENT C ONNECT TO P OSTGRE SQL SEVER VIA PG A DMIN Prof: Dr. Shu-Ching Chen TA: Haiman Tian.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
COP4710 D ATABASE M ANAGEMENT C ONNECT TO P OSTGRE SQL SEVER VIA PG A DMIN Prof: Dr. Shu-Ching Chen Ta: Hsin-Yu Ha.
XP New Perspectives on Microsoft Access 2002 Tutorial 41 Microsoft Access 2002 Tutorial 4 – Creating Forms and Reports.
CSCI 6962: Server-side Design and Programming
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
ASP.NET Programming with C# and SQL Server First Edition
Installing the SAFARIODBC.EXE For use with Excel May 3, 2002.
Copyright  Oracle Corporation, All rights reserved. 4 CMIS Powell Oracle Designer: Creating the Database Design CMIS Powell.
MySQL. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn The main subsystems in MySQL architecture The different storage.
Lesson 4.  After a table has been created, you may need to modify it. You can make many changes to a table—or other database object—using its property.
COP5725 D ATABASE M ANAGEMENT C ONNECT TO P OSTGRE SQL SEVER VIA PG A DMIN Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
MSOffice Access Microsoft® Office 2010: Illustrated Introductory 1 Part 1 ® Database & Table.
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.
Access Module Implementing a Database with Microsoft Access A Great Module on Your CD.
Software-Projekt 2008 Seminarvortrag“Short tutorial of MySql“ Wei Chen Verena Honsel.
Chapter 12 Introducing Databases. Objectives What a database is and which databases are typically used with ASP.NET pages What SQL is, how it looks, and.
2nd year Computer Science & Engineer
3 A Guide to MySQL.
Access Tutorial 2 Building a Database and Defining Table Relationships
Tutorial 1 Creating a Database
INTRODUCTION TO DATABASES (MICROSOFT ACCESS)
Trigger used in PosgreSQL
Y.-H. Chen International College Ming-Chuan University Fall, 2004
Working with Data Blocks and Frames
Working in the Forms Developer Environment
Access Tutorial 1 Creating a Database
COP 4540 Database Management
COP5725 Database Management Connect to PostgreSQL sever via pgAdmin
SQL MODELER - OPEN There are Three Ways to open the SQL Modeler
Introduction to Web programming
Prepared for Prof. JAI NAVLAKHA By Hsin-Yu Ha
COP4710 Database Management Connect to PostgreSQL sever via pgAdmin
Access Creating a Database
Access Creating a Database
ORACLE SQL Developer & SQLPLUS Statements
Exploring Microsoft Office Access 2010
ISC440: Web Programming 2 Server-side Scripting PHP 3
Aqua Data Studio.
SQL LANGUAGE and Relational Data Model TUTORIAL
COP4710 Database Management Connect to PostgreSQL sever via pgAdmin
Access Tutorial 1 Creating a Database
MODULE 7 Microsoft Access 2010
Tutorial 3 – Querying a Database
Teaching slides Chapter 8.
COP4710 Database Management Connect to PostgreSQL sever via pgAdmin
2016, Fall Pusan National University Taehoon Kim
Access Lesson 2 Creating a Database
Prepared for Prof. JAI NAVLAKHA By Hsin-Yu Ha
COP4710 Database Management Connect to PostgreSQL sever via pgAdmin
Computer Science Projects Database Theory / Prototypes
Access Tutorial 2 Building a Database and Defining Table Relationships
COP4710 Database Management Connect to PostgreSQL sever via pgAdmin
Access Tutorial 2 Building a Database and Defining Table Relationships
Prepared for Prof. JAI NAVLAKHA By Hsin-Yu Ha
COP4710 Database Management Connect to PostgreSQL sever via pgAdmin
Access Tutorial 1 Creating a Database
Access Tutorial 1 Creating a Database
Unit J: Creating a Database
Relationships While we are on the subject of Relationships, let’s take a quick look at them.
Presentation transcript:

COP5725 DATABASE MANAGEMENT POSTGRESQL TUTORIAL Prof: Dr. Shu-Ching Chen TA: Sheng Guan

Procedure outline Connect to server Connect to database Add tables through the gui Add tables through sql query tool Check your result after changing Run other sql queries in sql query tool PostgreSQL, often simply Postgres, is an object-relational database management system (ORDBMS) available for many platforms including Linux, FreeBSD, Solaris, Microsoft Windows and Mac OS X MySQL vs PostgreSQL is a decision many must make when approaching open-source relational database management systems. Both are time-proven solutions that compete strongly with proprietary database software. MySQL has long been assumed to be the faster but less full-featured of the two database systems, while PostgreSQL was assumed to be a more densely featured database system often described as an open-source version of Oracle. MySQL has been popular among various software projects because of its speed and ease of use, while PostgreSQL has had a close following from developers who come from an Oracle or SQL Server background. These assumptions, however, are mostly outdated and incorrect. MySQL has come a long way in adding advanced functionality while PostgreSQL dramatically improved its speed within the last few major releases. Many, however, are unaware of the convergence and still hold on to stereotypes based on MySQL 4.1 and PostgreSQL 7.4. The current versions are MySQL 5.7 and PostgreSQL 9.4.   For new projects, determine if you are going to port to closed software later on. In that case, PostgreSQL is closer to Oracle, and any code made for PostgreSQL will port to Oracle easily. MySQL has moved away from the SQL standard somewhat. PostgreSQL is more reliable because it is ACID (Atomicity, Consistency, Isolation, and Durability) compliant which means queries will maintain data integrity, and return the same output without error. MySQL is less reliable and not ACID compliant: The way it handles foreign key references, auditing and transactions make it less reliable. MySQL is good if you are thinking you may use code from other open source projects. Since it is widely used in smaller websites, there are plenty of add-ons, plugins and modules to optimize MySQL from popular software like Wordpress, Drupal and Joomla.

Connect to server Right click “COP5725” at the left “Object browser” panel to connect host server, and select “Connect”, and enter your password Right click and select “Connect” Input your panther ID

Connect to server If you are connecting from off-campus, you are required to input SSH tunnel password Input First Initial+ PantherID +Last Initial

Some tips Here if you encounter error, please check your PgAdmin version whether is updated – PgAdmin III 1.22 If you believe the order of your default first initial and last initial is wrong, please kindly try different combinations Sometimes, PgAdmin will go back to normal after you close the program and restart

Connect to database The server should now be shown in the left hand box and you can navigate your way round your database tables.

Add tables through the gui YourDB->Schemas->public->Tables, Right click to bring up create “New Table” dialogue

Add tables through the gui Here, we use a “cities” table as an example

Add tables through the gui Add attributes to the table: Click “Columns” tab, click “Add” button, and enter “name” in the Name text box, “Data type” as character and “Length” as 60

Add tables through the gui You can add more attributes to the table, such as “location” , “country”, and so on using the same way Your “cities” table will look like:

Add tables through the gui Finally, add one constraint for “cities” table. This would be the primary key. Click “Constraints” tab -> “Add” button. A new dialogue for adding a new primary key will show up. Enter the “pk_city_name” as the key name, Click “Columns”, and connect the key to a city name field of the table we created by selecting “name”. Then we will see that our primary key is created and added in the panel.

Add tables through the gui 1 2 4 3

Add tables through the gui Now we have specified the Table name, Attribute (column) names, Data types, Constraint (primary key , to prevent from duplicated records with the same city being added to the table).

Add tables through sql query tool SQL Icon Run SQL Query Run and Save SQL Query Write SQL query here

SQL command to create table You can select your query and press “F5” in space line to save and run the above query

Check your result after changing Similarly, we create a new “weather” table in the DB Now we want to check the changes: Now back to Object browser and right click “Your Database”, select Refresh, expand your database, you will notice our new “weather” table with columns and constraint (primary key) created.

Try other sql query in query tool ALTER TABLE products ADD CONSTRAINT namecheck CHECK (name <> ''); ALTER TABLE products ADD CONSTRAINT some_name UNIQUE (product_no); ALTER TABLE products ADD FOREIGN KEY (product_group_id) REFERENCES product_groups; ALTER TABLE products ALTER COLUMN product_no SET NOT NULL; DELETE FROM products WHERE price = 10;