system architecture: designing the database layer with java, jdbc and sql

Post on 11-Jan-2016

45 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

System Architecture: Designing the Database Layer with Java, JDBC and SQL. Databases for StressFreev1.3. StudentsDB - id, name, year, advisor, schedule, transcript TranscriptsDB - student, myMajors, myMinor, myCourseRecords, registrar - PowerPoint PPT Presentation

TRANSCRIPT

System Architecture:Designing the Database Layer

with Java, JDBC and SQL

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

2

Databases for StressFreev1.3

StudentsDB - id, name, year, advisor, schedule, transcriptTranscriptsDB - student, myMajors, myMinor,

myCourseRecords, registrarCoursesDB - id, title, distrib, sameAs, prerequisites,

myOfferingsOfferingsDB - id, section, labSection, semYear, capacity,

enrollment, myClassList, course, instructor, timeSlot

SchedulesDB - student, approved, finished, numClasses, myClassesInstructorsDB - name, myClasses, myAdviseesTimeSlotsDB - id, days, startTime, endTime

Note: Some of these names are not the same as in your StressFreev1.3.zuml model. We will use the Poseidon-generated Java classes (with these name changes) that are now in the folder StressFreev1.3 at the course web site.

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

3

SQL - Structured Query Language

A good database software tool (reliable, easy to use, free, and well integrated with Java).

• StressFree database creation, insertion, and queries are easily accomplished with simple SQL commands

• Java/mySQL interface (JDBC and SQL Connector/J) allows us to implement the component of StressFree in Java.

• The database component of StressFree will be part of the server side.

• A good tutorial on SQL (but it’s long!) is at:http://www.bowdoin.edu/~yzhuang/download/John

.Wiley.MySQL.pdf(Look at chapters 3 and 5 for starters.)

• So let’s learn a little about SQL and its Java interface…

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

4

SQL Overview

A Database is a collection of tables—It can be accessed by the ‘use’ SQL command.—Our database is called ‘csci260’

Each table has rows of values of a certain type—E.g., ‘TimeSlotsDB’ is a table inside the csci260 database with rows of values of type ‘TimeSlot’.

A table is a collection of columns, one for each variable

—It can be created and destroyed by the ‘create table’ and ‘drop table’ SQL commands.

—Information in tables can be accessed, added, changed, removed, or combined with other tables using ‘select’, ‘insert’, and other SQL commands.

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

5

Getting started: Connecting to the SQL Server— By command line -- our username is ‘csci260’ and our password is ‘regy’.— The host server is a separate machine outside the lab.— Only one database can be accessed at one time.

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

6

Getting started: Connecting to the SQL Server— In Java we need to import the java.sql.* classes— These provide all the methods for manipulating SQL databases and tables.— This program is in the Eclipse folder ‘workspace260Reg’ at the course web site.

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

7

Accessing a table in an SQL database— From the command line: use ‘show tables’ and ‘select’ commands

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

8

Accessing the same table from a Java program – Note that the names are those of the TimeSlot class variables.

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

9

Creating a new table in an SQL database (Java)

The above lines simulate the SQL commands:mysql> CREATE TABLE myTable (id int, name text);mysql> INSERT INTO myTable (id, name) VALUES (1, ‘Yip’);Mysql> …

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

10

Accessing and displaying data in a table (Java)

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

11

Accessing and displaying data in a table (Java)

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

12

Tables in the Database csci260: CoursesDB

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

13

Tables in the Database csci260: InstructorsDB

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

14

Tables in the Database csci260: OfferingsDB

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

15

Tables in the Database csci260: StudentsDB

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

16

Tables in the Database csci260: TranscriptsDB

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

17

1. Package functionally cohesive groupsE.g., Group Student, Transcript,

ScheduleE.g., Client classes vs Server classes

(as in the KnockKnock system)E.g., Database access classes

2. Package functionally related interfacesE.g., StressFree GUI

Relational cohesion =

Low cohesion indicates poor packaging.

System Architecture:Package Design Principles

Number of RelationsNumber of Classes

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

18

StressFreev1.3 Package Design

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

19

System Architecture:Deployment Diagrams

Identify software and hardware platforms where the system will run•Each box is a hardware/OS node in the system

•Links between boxes show communication paths and protocols

•Files and other artifacts can appear inside the boxes

•Boxes can be nested

© Lethbridge/Laganière 2001

Chapter 9: Architecting and designing software

20

StressFreev1.3 System Architecture

top related