Download presentation
Presentation is loading. Please wait.
Published bySophia Riley Modified over 6 years ago
1
Relational database and SQL MySQL LAMP SQL queries
SQL and MySQL Relational database and SQL MySQL LAMP SQL queries
2
Assignment 2 SQL and a MySQL Tutorial
Web database applications (Assignment 1, part II -- 5 reviews) Three-Tier Architectures Client tier: web browser software that interact with the applications Middle tier: application logic and communicate with db tier and client tier Database tier: database management system supports your data operation
3
Assignment 2: Using MySQL to issue SQL Queries
Relational database SQL queries: language to communicate with DBMS A MySQL Tutorial create db and tables insert data delete data select data
4
Relational Database and SQL
A particular kind of DBMS that is very good at relating information stored in one table to another –> to pull data from those tables and to join info from related tables to produce answers to the questions that can’t be answered from individual tables alone. SQL (Structured Query Language) standard database language.
5
MySQL Relational database system
Client/server architecture (101 simultaneous connections) SQL (table size for Linux = 4GB) Programming languages: C, C++, Java, Perl, PHP, Python, and Tcl Platform independence, security, and speed
6
LAMP Linux (operating system) Apache (web server system)
MySQL (database system) Perl/PHP (programming language – PHP for us) LAMP is an open source dream team LAMP is supported here by: athena
7
PHP Pure HTML static web site
PHP enable you to build dynamic web site A server-side scripting language designed specifically for the web Conceived in 1994 by Rasmus Lerdorf as one-man project then adapted by many PHP (Personal Hypertext Preprocessor)
8
SQL Queries When you use MySQL, you are using 2 programs(client/server): Database server is a program located on the machine where your data are stored. It listens for client requests coming from network Clients are programs that connect to the database server and issue queries to tell it what info they want
9
Benefits of Client/Server
The server provides concurrency control so that two users cannot modify the same record at the same time You don’t have to be logged in on the machine where your database is located
10
A MySQL Tutorial An excellent MySQL Tutorial in Chapter 1 of the following book: “MySQL™: The definitive guide to using, programming, and administering MySQL 4.1 and 5.0”, Third Edition by Paul DuBois (Safari Tech Books Online ) Establishing and terminating connection and issue SQL queries
11
Applications Examples of MySQL
UCSC Human Genome Project Working Draft LOCal: A Flexible Web-Based Microscope Reservation System – Univ. of Wisconsin, Madison You are going to find out more fine examples ….
12
Assignment 2: change password for MySQL
Following the instruction in Assignment 2, change your password in your MySQL account: The assigned Athena user name 122xxx is for both web server (Apatche) and database server (MySQL) The assigned password needs to be changed separately, once for web and once for db – you may use different passwords or keep them same Do it now …
13
Speedy MySQL Connection
Create a option file named .my.cnf in your home directory with content – this will save your time to log into MySQL every time: [client] User = your-mysql-username Password = your-password After creating the above file, chmod 600 .my.cnf Familiar yourself with MySQL by using a tutorial and you are ready to go
14
Database Building Basics
Create a table in MySQL: Method 1 – create it in MySQL – easy to make mistakes Method 2 – create/update in your favorite editor (linux or widow) first and then run mysql in Batch mode. Example: Edit mysql command to create a table “student” and save it as a file, “create_student.sql”. At linux prompt type the follow will create a table student in database webdb. mysql webdb < create_student.sql
15
Database Design Issues
Understanding the process and relations Objectstables, attributes columns, data types, relations index, primary keys Our database: 1 table student
16
The First Normal Form Columns with similar content must be eliminated
A table must be created for each group of associated data Each data must be identifiable by means of a primary key (unique index)
17
Second Normal Form Whenever the contents of columns repeat themselves, this means that the table must be divided into several sub-tables These table must be linked by foreign keys (cross reference)
18
A good example of normalizing a database
Third Normal Form Columns that are not directly related to the primary key must be eliminated A good example of normalizing a database
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.