Principles of Software Development

Slides:



Advertisements
Similar presentations
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Advertisements

A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
CSC 2720 Building Web Applications Database and SQL.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Phil Brewster  One of the first steps – identify the proper data types  Decide how data (in columns) should be stored and used.
CSCI 6962: Server-side Design and Programming
1 Overview of Databases. 2 Content Databases Example: Access Structure Query language (SQL)
Introduction to SQL Steve Perry
Web Services Week 8 Aims: –Using web services as front ends to databases Objectives: –Review of relational databases –Connecting to and querying databases.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
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.
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.
SQL 101 for Web Developers 14 November What is a database and why have one? Tables, relationships, normalization SQL – What SQL is and isn’t – CRUD:
Database Fred Durao What is a database? A database is any organized collection of data. Some examples of databases you may encounter in.
JDBC Tutorial CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
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.
CS453: Databases and State in Web Applications (Part 2) Prof. Tom Horton.
Database Design And Implementation. Done so far… Started a design of your own data model In Software Engineering, recognised the processes that occur.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
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.
Databases and SQL CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Introduction to MySQL  Working with MySQL and MySQL Workbench.
SQL CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Introduction to Database Programming with Python Gary Stewart
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.
Fundamental of Database Systems
2nd year Computer Science & Engineer
3 A Guide to MySQL.
Databases Stefano Grazioli.
INTRODUCTION TO DATABASES (MICROSOFT ACCESS)
Web Systems & Technologies
CS320 Web and Internet Programming SQL and MySQL
MySQL-Database Jouni Juntunen Oulu University of Applied Sciences
Chapter 6 - Database Implementation and Use
SQL in Oracle.
Fundamentals & Ethics of Information Systems IS 201
CS311 Database Management system
Chapter 4 Relational Databases
CS1222 Using Relational Databases and SQL
Database Management  .
Databases and Information Management
CS 174: Server-Side Web Programming February 12 Class Meeting
SQL 101.
Chapter 8 Working with Databases and MySQL
Database Fundamentals
Chapter 6 System and Application Software
Database.
CS1222 Using Relational Databases and SQL
Teaching slides Chapter 8.
Developing a Model-View-Controller Component for Joomla Part 3
CMPT 354: Database System I
Databases and Information Management
Data Management Innovations 2017 High level overview of DB
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
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
Chapter 6 System and Application Software
CS3220 Web and Internet Programming SQL and MySQL
Chapter 6 System and Application Software
CS1222 Using Relational Databases and SQL
DATABASE Purpose of database
Chapter 6 System and Application Software
INTRODUCTION A Database system is basically a computer based record keeping system. The collection of data, usually referred to as the database, contains.
CS4540 Special Topics in Web Development SQL and MS SQL
CS1222 Using Relational Databases and SQL
Presentation transcript:

Principles of Software Development Databases CSCI 201 Principles of Software Development Jeffrey Miller, Ph.D. jeffrey.miller@usc.edu

Outline Databases SQL Try It! USC CSCI 201L

Databases Database systems store data and provide a means of accessing, updating, manipulating, and analyzing data Databases are stored in files on a file system, but they are arranged in a manner that allows for fast queries and updates A Database Management System (DBMS) is designed for programmers, not casual users MySQL PostgreSQL Oracle Microsoft SQL Server IBM DB2 Apache Hadoop MongoDB Firebase USC CSCI 201L

Relational Databases Relational database management systems (RDBMS) provide three things Structure – the representation of the data Integrity – constraints on the data Language – means for accessing and manipulating data OverallGrades prefix num fname lname letterGrade CSCI 103 Sheldon Cooper A 104 Howard Wolowitz A- 201 Leonard Hofstadter B EE 101 B- Tables are called relations Columns are called attributes Rows are called tuples Connections are called relationships USC CSCI 201L

Relational Databases USC CSCI 201L OverallGrades prefix num fname lname letterGrade CSCI 103 Sheldon Cooper A 104 Howard Wolowitz A- 201 Leonard Hofstadter B EE 101 B- Non-normalized Class Student Normalized classID prefix num 1 CSCI 103 2 104 3 201 4 EE 101 studentID fname lname 1 Sheldon Cooper 2 Leonard Hofstadter 3 Howard Wolowitz 4 Rajesh Koothrappali Grades gradeID classID studentID letterGrade 1 A 2 3 A- 4 B 5 B- USC CSCI 201L

Primary and Foreign Keys A primary key is a column (or a combination of multiple columns) in a table that provides a unique reference to a row in the table A foreign key is a link between two tables that uniquely identifies a row in another table Class Student classID prefix num 1 CSCI 103 2 104 3 201 4 EE 101 5 102 studentID fname lname 1 Sheldon Cooper 2 Leonard Hofstadter 3 Howard Wolowitz 4 Rajesh Koothrappali Grades gradeID classID studentID letterGrade 1 A 2 3 A- 4 B 5 B-

Outline Databases SQL Try It!

SQL The Structured Query Language (SQL) is the primary language supported by DBMSs for accessing and manipulating data Some MySQL SQL statements you should know SHOW CREATE DATABASE USE CREATE TABLE INSERT UPDATE SELECT DELETE DROP If you are not familiar with SQL, there are many good tutorials online and our textbook has a good chapter reference as well USC CSCI 201L

SQL Scripts After installing a DBMS, you will be able to run SQL scripts SQL scripts are files that contain a collection of SQL statements that can be used for recreating databases and populating them with initial or testing data This is often used in the testing phase of software engineering to test different scenarios without requiring the QA engineers to insert all of the data manually USC CSCI 201L

Sample Script USC CSCI 201L 1 DROP DATABASE if exists StudentGrades; 2 CREATE DATABASE StudentGrades; 3 USE StudentGrades; 4 CREATE TABLE Student ( 5 studentID int(11) primary key not null auto_increment, 6 fname varchar(50) not null, 7 lname varchar(50) not null 8 ); 9 INSERT INTO Student (fname, lname) VALUES ('Sheldon', 'Cooper'); 10 INSERT INTO Student (fname, lname) VALUES ('Leonard', 'Hofstadter'); 11 CREATE TABLE Class ( 12 classID int(11) primary key not null auto_increment, 13 prefix varchar(5) not null, 14 num int(4) not null 15 ); 16 INSERT INTO Class (prefix, num) VALUES ('CSCI', 103); 17 INSERT INTO Class (prefix, num) VALUES ('CSCI', 104); 18 CREATE TABLE Grade ( 19 gradeID int(11) primary key not null auto_increment, 20 classID int(11) not null, 21 studentID int(11) not null, 22 letterGrade varchar(2) not null, 23 FOREIGN KEY fk1(classID) REFERENCES class(classID), 24 FOREIGN KEY fk2(studentID) REFERENCES student(studentID) 25 ); 26 INSERT INTO Grade (studentID, classID, letterGrade) VALUES (1, 1, 'A'); 27 INSERT INTO Grade (studentID, classID, letterGrade) VALUES (1, 2, 'A'); 28 INSERT INTO Grade (studentID, classID, letterGrade) VALUES (2, 1, 'A'); 29 INSERT INTO Grade (studentID, classID, letterGrade) VALUES (2, 2, ‘B'); Class Student classID prefix num 1 CSCI 103 2 104 studentID fname lname 1 Sheldon Cooper 2 Leonard Hofstadter Grade gradeID classID studentID letterGrade 1 A 2 3 4 B Longer script with more data is posted on the course web site USC CSCI 201L

SQL Visualization Tools A visualization tool connects to a database and allows execution of SQL statements The tool then will graphically display the results Free MySQL Clients Command line client (Windows, Mac, Linux) MySQL Workbench (Windows, Mac, Linux) Sequel Pro (Mac) Toad for MySQL (Windows) USC CSCI 201L

Executing SQL There are a few ways to execute SQL statements, which typically depend on the DBMS We often want to be able to access databases from within programs though This can be to insert, update, delete, or query the data The Java Database Connectivity (JDBC) drivers allow us to embed SQL in our Java code and execute those statements on a database programmatically USC CSCI 201L

Outline Databases SQL Try it! USC CSCI 201L

SQL Write SQL code to create the following database USC CSCI 201L Class Student classID prefix num 1 CSCI 103 2 104 3 201 4 EE 101 5 102 studentID fname lname 1 Sheldon Cooper 2 Leonard Hofstadter 3 Howard Wolowitz 4 Rajesh Koothrappali Grades gradeID classID studentID letterGrade 1 A 2 3 A- 4 B 5 B- USC CSCI 201L