Working with MySQL. SWC – 2011 2 Creating tables We know how to create a database in MySQL – an empty database Next step is to add tables to the database.

Slides:



Advertisements
Similar presentations
How to Create a Local Collection
Advertisements

Build a database I: Design tables for a new Access database
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)MySQL Recap.
Quick-and-dirty.  Commands end in a semi-colon ◦ If you forget, another prompt line shows up  Either continue the command or…  End it with a semi-colon.
Maintenance Modifying the data –Add records –Delete records –Update records Modifying the design –Add fields into tables –Remove fields from a table –Change.
Database A collection of related information stored on a computer and organized in a manner that allows access, retrieval, and use of that data.
SQL Data Definition II Stanislava Armstrong 1SQL Data Definition II.
Creating a Blank Database 1. Open up Microsoft Access 2. Click on Blank document button 3. On the right panel, Specify the location for saving your database.
DT211 Stage 2 Databases Lab 1. Get to know SQL Server SQL server has 2 parts: –A client, running on your machine, in the lab. You access the database.
Structured Query Language SQL: An Introduction. SQL (Pronounced S.Q.L) The standard user and application program interface to a relational database is.
Database Design.  Define a table for each entity  Give the table the same name as the entity  Make the primary key the same as the identifier of the.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
BSC Food Distribution 8181 NW 36 Street, Suite 14-D Doral, FL Phone: Fax:
Advanced Tables Lesson 9. Objectives Creating a Custom Table When a table template doesn’t suit your needs, you can create a custom table in Design view.
MySql In Action Step by step method to create your own database.
1 Microsoft Access 2002 Tutorial 5 – Enhancing a Table’s Design, and Creating Advanced Queries and Custom Forms.
CHAPTER 9 DATABASE MANAGEMENT © Prepared By: Razif Razali.
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
ACCESS. » Access is a database management system. » This system lets you create and process data. » A database is a collection of data that is organized.
INTERNET APPLICATION DEVELOPMENT For More visit:
LSP 121 Week 1 Intro to Databases. Welcome to LSP 121 Quantitative Reasoning and Technological Literacy II Continuation of quantitative data concepts.
Working with Derby. RHS – Creating tables We know how to create a database in Derby – an empty database Next step is to add tables to the database.
Create Database Tables
1 MySQL and phpMyAdmin. 2 Navigate to and log on (username: pmadmin)
Mail merge letters are used to send the same or similar documents to many different people. Since they contain the recipient’s name, address, and other.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
PHP meets MySQL.
Microsoft Access 2003 Define some key Access terminology: Field – A single characteristic or attribute of a person, place, object, event, or idea. Record.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Chapter 17 Creating a Database.
M1G Introduction to Database Development 2. Creating a Database.
Intro to MySQL 1. Open a browser and enter the following address: It should lead to a log in screen. If your name is.
Stored Procedure. Objective At the end of the session you will be able to know :  What are Stored Procedures?  Create a Stored Procedure  Execute a.
Using Microsoft Access Now that data has been entered we are ready to sort or data To do this, first click on the field label which you want to sort If.
Database Copyright 2006 South-Western/Thomson Learning.
# 1# 1 Creating Tables, Setting Constraints, and Datatypes What is a constraint and why do we use it? What is a datatype? What does CHAR mean? CS 105.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
CSC 240 (Blum)1 Introduction to Access CSC 240 (Blum)2 Click on the Access desktop icon or go to Start/Programs/Microsoft Office/Microsoft Office.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
Database Basics BCIS 3680 Enterprise Programming.
CSC 240 (Blum)1 Introduction to Access CSC 240 (Blum)2 Click on the Access desktop icon or go to Start/All Programs/Microsoft Office/Microsoft Office.
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.
Microsoft Access Database Creation and Management.
Mr C Johnston ICT Teacher
Task #1 Create a relational database on computers in computer classroom 308, using MySQL server and any client. Create the same database, using MS Access.
Chapter 8 Manipulating MySQL Databases with PHP PHP Programming with MySQL 2 nd Edition.
Chapter 9 Vocabulary Databases. 1.Table – a collection of information, or data arranged in columns and rows. 2.Record – all of the information about one.
Understand Primary, Foreign, and Composite Keys Database Administration Fundamentals LESSON 4.2.
1 MySQL and SQL. 2 Topics  Introducing Relational Databases  Terminology  Managing Databases MySQL and SQL.
Classwork: Common Errors Primary keys: don’t forget them! Primary keys: choose the best one! – “Name” and “birthday” are not the best choices. – “Phone.
Connecting (relating) Data Tables to get Custom Records (Queries) Database Basics.
LIS618 last lecture building a search interface Thomas Krichel
Key Applications Module Lesson 22 — Managing and Reporting Database Information Computer Literacy BASICS.
Lecture Access – Queries. What’s a Query? A question you ask a database –ie: “Who are my Stockton customers?” –ie: “How much did Bob sell on the 14th?”
Introduction to MySQL Ullman Chapter 4. Introduction MySQL most popular open-source database application Is commonly used with PHP We will learn basics.
SQL constrains and keys. SORTED RESULTS Sort the results by a specified criterion SELECT columns FROM tables WHERE predicates ORDER BY column ASC/DESC;
1 CPE 332 Introduction DBMS: Relational Database Managment Systems Instructor:Suthep Madarasmi, Ph.D. ดร. สุเทพ มาดารัศมี
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
MYSQL AND MYSQL WORKBENCH MIS2502 Data Analytics.
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
Copyright © 2014 Pearson Canada Inc. Ext. 5b-1 Copyright © 2014 Pearson Canada Inc. Application Extension 5b Using Microsoft Access Part 2: Using Information.
How to: SQL By: Sam Loch.
Chapter 5 Introduction to SQL.
MySQL - Creating donorof database offline
Structured Query Language (Data definition Language)
Introduction to Access 2003
Creating and Modifying Queries
PHPMyAdmin.
PHP and MySQL.
Presentation transcript:

Working with MySQL

SWC – Creating tables We know how to create a database in MySQL – an empty database Next step is to add tables to the database After adding tables, we can enter data into the tables Remember; design your tables BEFORE using MySQL to enter them

SWC – Creating tables Before using a database, we must connect to it Right-click on database, and choose ”Connect”

SWC – Creating tables Enter whatever we chose when crea- ting the database

SWC – Creating tables Now we can access the tables in the database – but there are none yet

SWC – Creating tables Right-click on ”Tables”, and choose ”Create table”

SWC – Creating tables

SWC – Creating tables Recall what we need in order to define a table –A proper name for the table –A set of field definitions – a name and a type for each field –A key field – one or more fields the combination of which is always unique

SWC – Creating tables Enter a proper name for the table

SWC – Creating tables For each data field (also called column), we must add quite a lot of information: –Column name: Name of the data field –Key: Is the field part of the key field –Index: Leave as-is… –Null: Can we omit the value –Unique: Must the value be unique –Data type: Proper type of data –Size: How large can the data be

SWC – Creating tables Example: a Name field –Column name: Name –Key: Yes –Null: No –Unique: (decided by choosing ”Key”) –Data type: VARCHAR (means ”String”) –Size: 50 (how long can a name be…?)

SWC – Creating tables Example: a Phone field –Column name: Phone –Key: No –Null: No –Unique: No –Data type: INT (number)

SWC – Creating tables

SWC – Creating tables

SWC – Creating tables A database called School A table called student Five data fields Red indicates a key field

SWC – Creating tables We can add more data fields later Right-click on the table, choose ”Add Column…”

SWC – Creating tables Exercise –Create a database called WebShop in MySQL –Create three tables in WebShop, called Item, Customer, Sale –Definitions of the tables are given below (key fields are in red) –Remember to choose proper data types! Item ItemNumber ItemName Price Weight NumberInStock IsFragile Description Customer CustomerNumber Name Address ZipCode ClubMember LastSale Sale TransactionNumber ItemNumber Date NumberOfItems TotalAmount SentToCustomer PaymentReceived

SWC – Adding data With the table defini- tion in place, we can now begin to add data to the table Right-click on the table, choose ”View Data…”

SWC – Adding data Data in the table is shown here (none yet….)

SWC – Adding data Press this icon to add new data

SWC – Adding data Type in data for each record

SWC – Adding data

SWC – Adding data Table now con- tains 3 records

SWC – Adding data And so on, and so on…

SWC – Adding data What can go wrong…? We might try to type in some data, that does not match the type specification for a particular field MySQL will complain…

SWC – Adding data What is wrong here…?

SWC – Adding data

SWC – Adding data The error messages can be more or less easy to understand… It is almost always a matter of trying to enter data of the wrong type Might also be data of incorrect size Some errors are more subtle, like a wrong date ( )

SWC – Adding data What is this…? An SQL query!

SWC – Adding data Exercise –Add a few records to the tables created in the earlier exercise. Try to experiment with the data, such that you also try to add some data with errors. Observe the errors messages that MySQL returns when data has errors –Do you now feel comfortable working with MySQL, with regards to creating databases, tables and fields, and entering data into tables? If not, then try to invent some more tables, enter them into a database, and enter some data into the tables