CS 160 and CMPE/SE 131 Software Engineering March 15 Class Meeting Department of Computer Science Department of Computer Engineering San José State University.

Slides:



Advertisements
Similar presentations
J4www/jea Week 3 Version Slide edits: nas1 Format of lecture: Assignment context: CRUD - “update details” JSP models.
Advertisements

CS 185C/286: The History of Computing October 31 Class Meeting Department of Computer Science San Jose State University Fall 2011 Instructor: Ron Mak
WELL-DESIGNED DATABASES Process faster Easy to develop and maintain Easy to read and write code.
Chapter 12 Information Systems. 2 Chapter Goals Define the role of general information systems Explain how spreadsheets are organized Create spreadsheets.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
Information storage: Introduction of database 10/7/2004 Xiangming Mu.
CS 160: Software Engineering November 10 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
Server-side Scripting Powering the webs favourite services.
Interacting With Data Databases.
Database Programming in Java Corresponds with Chapter 32, 33.
CS 157B: Database Management Systems II May 8 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak
CS 160: Software Engineering October 8 Class Meeting
CS 157B: Database Management Systems II January 30 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak.
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
Summary Data Modeling SDLC What is Data Modeling Application Audience and Services Entities Attributes Relationships Entity Relationship Diagrams Conceptual,Logical.
2005 SPRING CSMUIntroduction to Information Management1 Organizing Data John Sum Institute of Technology Management National Chung Hsing University.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
CMPE 226 Database Systems September 16 Class Meeting Department of Computer Engineering San Jose State University Fall 2015 Instructor: Ron Mak
CS 174: Web Programming September 23 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Databases From A to Boyce Codd. What is a database? It depends on your point of view. For Manovich, a database is a means of structuring information in.
CS 174: Web Programming September 21 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
CS 157B: Database Management Systems II February 6 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Introduction to Internet Databases MySQL Database System Database Systems.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
PHP and MySQL CS How Web Site Architectures Work  User’s browser sends HTTP request.  The request may be a form where the action is to call PHP.
CS 157B: Database Management Systems II February 4 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak.
CS 157B: Database Management Systems II January 28 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak.
CS 160: Software Engineering October 1 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
CS 160: Software Engineering October 15 Class Meeting
CS 160: Software Engineering October 6 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
Lecture 1: Overview of CSCI 485 Notes: I presented parts of this lecture as a keynote at Educator’s Symposium of OOPSLA Shahram Ghandeharizadeh Associate.
CS 174: Web Programming August 31 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
CS 1308 Computer Literacy and the Internet
CS 153: Concepts of Compiler Design August 26 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
INFO1408 Database Design Concepts Week 15: Introduction to Database Management Systems.
CMPE 226 Database Systems September 23 Class Meeting Department of Computer Engineering San Jose State University Fall 2015 Instructor: Ron Mak
CMPE 226 Database Systems October 7 Class Meeting Department of Computer Engineering San Jose State University Fall 2015 Instructor: Ron Mak
CS 151: Object-Oriented Design October 15 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
CS 174: Web Programming October 14 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Basics of JDBC Session 14.
CS 174: Web Programming November 2 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
CS 235: User Interface Design March 17 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
1 A Very Brief Introduction to Relational Databases.
CS 160 and CMPE/SE 131 Software Engineering February 11 Class Meeting Department of Computer Science Department of Computer Engineering San José State.
CMPE 226 Database Systems April 19 Class Meeting Department of Computer Engineering San Jose State University Spring 2016 Instructor: Ron Mak
CS 160 and CMPE/SE 131 Software Engineering March 10 Class Meeting Department of Computer Science Department of Computer Engineering San José State University.
CS 160 and CMPE/SE 131 Software Engineering March 8 Class Meeting Department of Computer Science Department of Computer Engineering San José State University.
CS 160 and CMPE/SE 131 Software Engineering March 22 Class Meeting Department of Computer Science Department of Computer Engineering San José State University.
/16 Final Project Report By Facializer Team Final Project Report Eagle, Leo, Bessie, Five, Evan Dan, Kyle, Ben, Caleb.
SQL Basics Review Reviewing what we’ve learned so far…….
CS 160 and CMPE/SE 131 Software Engineering May 12 Class Meeting Department of Computer Science Department of Computer Engineering San José State University.
CMPE 226 Database Systems April 12 Class Meeting Department of Computer Engineering San Jose State University Spring 2016 Instructor: Ron Mak
CS 157B: Database Management Systems II January 23 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak.
Introduction to Database Programming with Python Gary Stewart
CMPE Database Systems Workshop June 12 Class Meeting
Chapter 6 - Database Implementation and Use
CMPE 280 Web UI Design and Development October 24 Class Meeting
CIS 336 strCompetitive Success/tutorialrank.com
CIS 336 str Education for Service-- tutorialrank.com.
CMPE 226 Database Systems February 21 Class Meeting
CS 174: Server-Side Web Programming February 12 Class Meeting
Teaching slides Chapter 8.
CMPE 226 Database Systems February 28 Class Meeting
CMPE/SE 131 Software Engineering March 9 Class Meeting
A Very Brief Introduction to Relational Databases
Summary Data Modeling SDLC What is Data Modeling
Lecture 1: Overview of CSCI 485 Notes: I presented parts of this lecture as a keynote at Educator’s Symposium of OOPSLA Shahram Ghandeharizadeh Director.
CMPE/SE 131 Software Engineering March 7 Class Meeting
Presentation transcript:

CS 160 and CMPE/SE 131 Software Engineering March 15 Class Meeting Department of Computer Science Department of Computer Engineering San José State University Spring 2016 Instructor: Ron Mak

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak Assignment #5  Initial draft of your Design Document.  Document the design of your application. MVC architecture UML package and class diagrams UML sequence diagram  Document the design of your database. Conceptual model: entity-relationship (ER) diagram Logical model: relational schema 2

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 3 SQL  Structured Query Language (SQL) An industry standard But has many proprietary extensions  Language for managing data in a relational database. Create and drop (delete) databases Create, alter, and drop tables of a database Retrieve, insert, update, and delete data in the tables.

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 4 SQL Query Examples  What is the class code of the Java programming class? CodeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems109 Class SELECT code FROM class WHERE subject = 'Java programming' | code | | 926 | Source tablesDesired fields Selection criteria

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 5 SQL Query Examples, cont’d  Who is teaching Java programming? IdLastFirst 7003RogersTom 7008ThompsonArt 7012LaneJohn 7051FlynnMabel CodeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems109 ClassTeacher SELECT first, last FROM teacher, class WHERE id = teacher_id AND subject = 'Java programming' | first | last | | Tom | Rogers | Selecting from multiple tables is called a join.

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 6 SQL Query Examples, cont’d  What subjects does John Lane teach? SELECT code, subject FROM teacher, class WHERE last = 'Lane' AND first = 'John' AND id = teacher_id | code | subject | | 951 | Software engineering | | 974 | Operating systems | IdLastFirst 7003RogersTom 7008ThompsonArt 7012LaneJohn 7051FlynnMabel CodeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems109 ClassTeacher

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 7 SQL Query Examples, cont’d  Who is taking Java programming? IdLastFirst 1001DoeJohn 1005NovakTim 1009KleinLeslie 1014JaneMary 1021SmithKim CodeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems109 Student_idClass_code SELECT id, last, first FROM student, class, student_class WHERE subject = 'Java programming' AND code = class_code AND id = student_id | id | last | first | | 1001 | Doe | John | | 1021 | Smith | Kim | Class Student_Class Student

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 8 SQL Query Examples, cont’d  What classes is John Doe taking? IdLastFirst 1001DoeJohn 1005NovakTim 1009KleinLeslie 1014JaneMary 1021SmithKim CodeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems109 Student_idClass_code SELECT code, subject FROM student, class, student_class WHERE last = 'Doe' AND first = 'John' AND id = student_id AND code = class_code | code | subject | | 908 | Data structures | | 926 | Java programming | | 951 | Software engineering | ClassStudent Student_Class

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 9 SQL Query Examples, cont’d  Who are John Lane’s students? IdLastFirst 1001DoeJohn 1005NovakTim 1009KleinLeslie 1014JaneMary 1021SmithKim CodeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems109 Student_idClass_code SELECT student.first, student.last, subject FROM student, teacher, class, student_class WHERE teacher.last = 'Lane' AND teacher.first = 'John' AND teacher_id = teacher.id AND code = class_code AND student.id = student_id ORDER BY subject, student.last | first | last | subject | | Tim | Novak | Operating systems | | Kim | Smith | Operating systems | | John | Doe | Software engineering | IdLastFirst 7003RogersTom 7008ThompsonArt 7012LaneJohn 7051FlynnMabel Teacher StudentClass Student_Class

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak More about Joins  What is the id, name, vendor, and price of each product? 10 SELECT productid, productname, vendorname, productprice FROM product, vendor WHERE product.vendorid = vendor.vendorid; Qualified names Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak More about Joins, cont’d  Without a join condition, you get a Cartesian product.  Each record of one table matched with every record from the other table. 11

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak More about Joins, cont’d 12 SELECT * FROM product, vendor; Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak More about Joins, cont’d  Include the join condition 13 WHERE product.vendorid = vendor.vendorid

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 14 Database Record Insert, Update, and Delete  There are SQL statements to insert, update, and delete records. INSERT INTO teacher (id, last, first) VALUES (7088, 'Mak', 'Ron'), (7090, 'Wilson', 'Brian') UPDATE teacher SET first = 'Ronald' WHERE first = 'Ron' DELETE FROM teacher WHERE id = 7090 This can update multiple records!

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak SQL to Add Rows  Add rows to the Class table: 15 CodeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems 109 INSERT INTO class (code, teacher_id, subject, room) VALUES (908, 7008, 'Data structures', 114), (926, 7003, 'Java programming', 101), (931, 7051, 'Compilers', 222), (951, 7012, 'Software engineering', 210), (978, 7012, 'Operating systems', 109);

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak SQL to Create and Drop a Database  Examples to create:  Examples to drop: 16 CREATE DATABASE school3; CREATE DATABASE IF NOT EXISTS school3; DROP DATABASE school3; DROP DATABASE IF EXISTS school3;

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak CREATE TABLE class ( code INT PRIMARY KEY, teacher_id INT NOT NULL, subject VARCHAR(32) NOT NULL, room INT NOT NULL ); SQL to Create a Table  First we create a new database and connect to it:  Create the Class table: 17 CREATE DATABASE school3; USE school3; CodeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems 109

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak SQL Script create_school.sql 18 DROP DATABASE IF EXISTS school3; CREATE DATABASE school3; USE school3; CREATE TABLE class ( codeINTPRIMARY KEY, teacher_id INT NOT NULL, subject VARCHAR(32)NOT NULL, room INT NOT NULL, ); INSERT INTO class (code, teacher_id, subject, room) VALUES(908, 7008, 'Data structures', 114), (926, 7003, 'Java programming', 101), (931, 7051, 'Compilers', 222), (951, 7012, 'Software engineering', 210), (978, 7012, 'Operating systems', 109);

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak SQL Script create_school.sql, cont’d 19 CREATE TABLE contact_info ( idINTPRIMARY KEY, _addressVARCHAR(32)NOT NULL ); INSERT INTO contact_info (id, _address) VALUES(1, (2, (3, (4, (5, (6, (7, (8, (9,

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak SQL Script create_school.sql, cont’d 20 CREATE TABLE teacher ( idINTPRIMARY KEY, lastVARCHAR(32)NOT NULL, firstVARCHAR(32)NOT NULL, contact_idINTREFERENCES contact_info(id) ); INSERT INTO teacher (id, last, first, contact_id) VALUES(7003, 'Rogers','Tom',6), (7008, 'Thompson','Art',7), (7012, 'Lane','John’,8), (7051, 'Flynn','Mabel',9);

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 21 Database Connection Pool  Opening and closing a database connection are slow operations. A running web application may have many simultaneous threads each making data requests, and each request needs a connection.  Solution: Create a pool of open connections. When a data request needs a connection, it gets an open connection from the pool. When the request is done, it returns the open connection to the pool for another request to use. The pool can grow and shrink based on usage.

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 22 Database Connection Pool, cont’d  Rails supports database connection pools.  See online tutorials and documentation: and-database-connections and-database-connections ectionAdapters/ConnectionPool.html ectionAdapters/ConnectionPool.html Connection pool Application threadsDatabase OPEN CONNECTIONS

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 23 Data Access Layer  Databases and SQL are extremely powerful.  Let the database do what it’s good at doing, and let Ruby do what it’s good at doing. For example, don’t write Ruby code to sort the retrieved records – let the database do that!

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 24 Data Access Layer, cont’d  Add a data access layer to your server-side architecture.  The data access layer contains all the database API calls and manages the database connection pool.  Keep the rest of your application loosely-coupled from the database code.  With active records and object-relational mapping, the rest of your application deals only with objects, not result sets.

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 25 SERVER SIDE Multilayered Server-Side Architecture Presentation Layer View Objects Application Layer Controller Objects Data Access Layer Fetch and Store Model Objects Database

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 26 Midterm on Thursday  Open book, notes, laptop, Internet.  No communication or sharing with anyone else during the exam!  It will cover everything we’ve done so far: lectures assignments  Be familiar with the books, especially the blue Rails Crash Course book.  Be able to use ERDPlus to draw ER diagrams and relational schemas.

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 27 Example Midterm Questions  Briefly describe the contents of each of the following: Requirements specification Software prototype Conceptual design Design document

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 28 Example Midterm Questions, cont’d  Consider the use case where a user moves a file from one directory into another within the file system. Suppose you implemented it with a graphical user interface (GUI) based on the model-view-controller (MVC) architecture. The user does the file move by dragging the image of a document on the screen with the mouse from one folder image into another. Identify the model, the view, and the controller objects. Draw a UML sequence diagram of the interaction described by this use case.

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 29 Example Midterm Questions, cont’d  Model File system components Physical files and directories that exist on disk  View GUI objects Folders and documents as shown on the screen

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 30 Example Midterm Questions, cont’d  Controller The interface (“bridge”) between the GUI and the file system. The code that translates the GUI actions to operations on the underlying file system.

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 31 Example Midterm Questions, cont’d User Source Folder GUI-FS Bridge File System Destination Folder select document send move command with source file path and destination directory path confirm file move confirm selection end drag send destination folder info detach document from source folder send source folder and source document infostart drag confirm file movedisplay document in destination folder

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 32 Example Midterm Questions, cont’d  Suppose a teaching assistant for this Software Engineering class wanted to build a relational database to keep track of the project teams.  His first attempt at the database consists of a single table, as shown in the relational schema.

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 33 Example Midterm Questions, cont’d  For each of the following queries, either write the SQL statement to perform the query based on this database, or explain why the query would be difficult to do. What are the name and URL of team Alpha’s product? SELECT product_name, product_URL FROM team WHERE team_name = ‘ Alpha ’

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 34 Example Midterm Questions, cont’d Who’s on team Beta? Which team is Mary Jones on and what is her project grade? Difficult (tedious, at least) to do because of the repeated student fields. Each first name/last name pair would need to be listed separately in the SELECT clause. Also difficult to do because the test for Mary Jones would have to be duplicated for each student in the row and then OR’d together.

Computer Science Dept. Spring 2016: March 15 CS 160 and CMPE/SE 131: Software Engineering © R. Mak 35 Example Midterm Questions, cont’d  Normalize to 2NF the project team database. Remember that each student on a particular project team will receive the same project grade.