Intro to Relational Databases

Slides:



Advertisements
Similar presentations
Results of the survey and relational dbs Fall 2011.
Advertisements

Database Access using SQL
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
CSC 2720 Building Web Applications Database and SQL.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial Password: UWPstudent Password is case sensitive.
Databases Dan Otero Alex Loddengaard
Phil Brewster  One of the first steps – identify the proper data types  Decide how data (in columns) should be stored and used.
Data Persistence and Object-Relational Mapping Slides by James Brucker, used with his permission 1.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
MySQL Dr. Hsiang-Fu Yu National Taipei University of Education
CSCI 6962: Server-side Design and Programming
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
Database Access using SQL
Web Design: Basic to Advanced Techniques Fall 2010 Mondays 7-9pm 200 Sutardja-Dai Hall Databases & SQL Lecture Code:
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Chapter 4 Introduction to MySQL. MySQL “the world’s most popular open-source database application” “commonly used with PHP”
CSC 2720 Building Web Applications Database and SQL.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2015, Fred McClurg, All Rights.
11 3 / 12 CHAPTER Databases MIS105 Lec15 Irfan Ahmed Ilyas.
Course FAQ’s I do not have any knowledge on SQL concepts or Database Testing. Will this course helps me to get through all the concepts? What kind of.
Visual Programing SQL Overview Section 1.
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
CP476 Internet Computing Perl CGI and MySql 1 Relational Databases –A database is a collection of data organized to allow relatively easy access for retrievals,
Database Access using SQL An introduction to MySQL.
Introduction to MySQL Ullman Chapter 4. Introduction MySQL most popular open-source database application Is commonly used with PHP We will learn basics.
Chapter 3: Relational Databases
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Introduction to Databases & SQL Ahmet Sacan. What you’ll need Firefox, SQLite plugin Mirdb and Targetscan databases.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Intro to MySQL.
Introduction to Database Programming with Python Gary Stewart
Marketing Analytics: Database Query with MySQL Disclaimer: All logos, photos, etc. used in this presentation are the property of their respective copyright.
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.
CS 3630 Database Design and Implementation
CS320 Web and Internet Programming SQL and MySQL
Managing Tables, Data Integrity, Constraints by Adrienne Watt
Client/Server Databases and the Oracle 10g Relational Database
Data Definition and Data Types
PGT(CS) ,KV JHAGRAKHAND
Introduction to MySQL.
Database Keys and Constraints
Applied CyberInfrastructure Concepts Fall 2017
Principles of Software Development
CS1222 Using Relational Databases and SQL
ISC440: Web Programming 2 Server-side Scripting PHP 3
Lecturer: Mukhtar Mohamed Ali “Hakaale”
CS1222 Using Relational Databases and SQL
MySQL Dr. Hsiang-Fu Yu National Taipei University of Education
What is a Database? A collection of data organized in a manner that allows access, retrieval, and use of that data.
Defining a Database Schema
Unit I-2.
Paul Jacobs The iSchool University of Maryland Thursday, Oct. 5, 2017
Chapter 7 Using SQL in Applications
CS1222 Using Relational Databases and SQL
CS1222 Using Relational Databases and SQL
CS3220 Web and Internet Programming SQL and MySQL
Physical Data Modeling – Implementation
Data Definition Language
Chapter # 7 Introduction to Structured Query Language (SQL) Part I.
Chapter 4 Introduction to MySQL.
MySQL Database System Installation Overview SQL summary
CS3220 Web and Internet Programming SQL and MySQL
CS1222 Using Relational Databases and SQL
MySQL Database System Installation Overview SQL summary
CS1222 Using Relational Databases and SQL
Presentation transcript:

Intro to Relational Databases A very basic introduction James Brucker

A Database Structure Database A database contains schema, which describe the organization of the database. A schema can contain: tables - containing the data index files - for fast lookup constraints on data stored procedures triggers - actions that cause events Schema Table field1: t1 field2: t2 field3: t3 Table field1: t1 field2: t2 field3: t3 Table field1: t1 field2: t2 field3: t3 Constaint indexes indexes indexes

Table records (rows) fields (columns) A table contains the actual data in records (rows). A record is composed of fields (columns). Each record contains one set of data values. +------+------------+-------+-------------+---------+ | ID | Name | CCode | District | Populatn +------+---------------+------------------+--------+ | 3320 | Bangkok | THA | Bangkok | 6320174 | | 3321 | Nonthaburi | THA | Nonthaburi | 292100 | | 3323 | Chiang Mai | THA | Chiang Mai | 171100 | records (rows) fields (columns)

Structure of a Table Every field has: a name a data type and length To view the structure of a table use: DESCRIBE tablename sql> DESCRIBE City; +-------------+-----------+-----+-----+---------+----------------+ | Field | Type | Null| Key | Default | Extra | | ID | int(11) | NO | PRI | | auto_increment | | Name | char(35) | NO | | | | | CountryCode | char(3) | NO | | | | | District | char(20) | NO | | | | | Population | int(11) | NO | | 0 | |

Fields have Data Types Each field has a data type that identifies the kind of data it can store. The data type also determines the size of the field. INTEGER usually 4 byte integers FLOAT usually 8 byte (like Java double) DECIMAL like Java BigDecimal BOOLEAN CHAR(10) string of size 10 chars VARCHAR(40) variable length string

Primary Key - field to Identify Rows A table usually has a primary key field that uniquely identifies each row (record) of data. Each record must have a distinct value of primary key The primary key is used to relate (join) tables. ID is the primary key in City table. +------+------------+-------+-------------+---------+ | ID | Name | CCode | District | Populatn +------+---------------+------------------+---------+ | 3320 | Bangkok | THA | Bangkok | 6320174 | | 3321 | Nonthaburi | THA | Nonthaburi | 292100 | | 3323 | Chiang Mai | THA | Chiang Mai | 171100 |

Primary Key is usually just a number Primary key is usually a meaningless integer assigned by the database system. Example: ID of City table has is arbitrary number. ID is the primary key +------+------------+-------+-------------+---------+ | ID | Name | CCode | District | Populatn +------+---------------+------------------+---------+ | 3320 | Bangkok | THA | Bangkok | 6320174 | | 3321 | Nonthaburi | THA | Nonthaburi | 292100 | | 3323 | Chiang Mai | THA | Chiang Mai | 171100 |

...but it may have meaning Primary key can be a part of the data, if you can guarantee it always has unique, non-null value. Not necessarily a number (but integers are preferred). Example: CountryCode (3-letter) is PK for Country Primary Key +------+----------------+-------------+--------------+ | Code | Name | Continent | Population | | AFG | Afghanistan | Asia | | | NLD | Netherlands | Europe | | | THA | Thailand | Asia | | | USA | United States..| North America| |

Relating Data in Tables A relational database lets you connect data in different tables using expressions. This is the power of a relational database. Example: The CountryCode (in City table) tells you which Country the city is part of. City ID (PK) Name CountryCode (FK) Population District Country Code (PK) Name Continent Capital ... CountryCode

Joining Tables Relate or "join" tables using a condition (an expression). Use "table.field" to qualify a field name: City.countrycode = Country.code City ID (PK) Name CountryCode (FK) Population District Country Code (PK) Name Continent Capital ... * 1

What Can You Do? Databases provide 4 basic operations: Save data Find and retrieve data (search) Update existing data Delete

Characteristics Databases do more than just collect data. Database servers provide: Access control (who can read/write) Gaurantee data integrity All-or-nothing updates Transaction processing & logging … and more.

Database Software Q1: Name a database program you know. There are many high quality, scalable database software applications... even for free. Q1: Name a database program you know. Q2: Have you used it? How?

Two Kinds of Database Apps Client-Server: a server manages one or more databases, and controls access. server often runs on its own machine access typically over a network must set-up server in advance Embedded: the database provider is included in your application. no separate server access locally, in code no need to set-up a server

Client - Server Databases Database Server is a separate process running on a host. Clients can run on any machine. Many programs may be clients using a standard API. Examples: MySQL, MariaDB, Postgresql, Oracle Server (mysqld) "mysql" utility Java app using JDBC server controls access to database PHP client Client side Server side

Why the "d" in mysqld ? Question: Why "d"? The MySQL server is named "mysqld". Question: Why "d"? Other programs ending in "d": ftpd - ftp server httpd - Apache HTTP server sshd - Secure Shell server Server (mysqld) database

Embedded Databases "Embedded" database manager is included (embedded) in your application. In Java, its a JAR file. No separate database server Usually light-weight (don't use much memory/cpu) Examples: Derby, H2, HyperSQL, SQLite YourApp Connection embedded database (JAR file) include the database software (jar) with your application. Software in JAR creates and manages database.

Database Management System SELECT * FROM city WHERE name LIKE Ban% Database Manager Client Control access to the database. authentication enforce permissions data integrity access services Database: a structured, self-describing collection of data. User Interface & communication protocol