clients and server. clients and servers a server provides a service such as dispensing files. a...
TRANSCRIPT
![Page 1: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/1.jpg)
Clients and Server
![Page 2: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/2.jpg)
Clients and serversA server provides a service such as dispensing files.A client calls on a service.The distinction is not hard and fast a server may act as a client to another server.
![Page 3: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/3.jpg)
A server acting as a client
In an ecommerce application a Web server might call on the service of a database server in order to access some data such as catalogue records
![Page 4: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/4.jpg)
Some serversFile serversDatabase serversGroupware serversWeb serversMail serversObject serversPrint servers
![Page 5: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/5.jpg)
Web serversIn ecommerce terms the most important type of serverDeal with in detail laterStores HTML files and dispenses them to clientsProcesses forms detailsCommunicates with other servers, for example database servers
![Page 6: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/6.jpg)
Database serversNext to web servers the most important type of server for ecommerceExplained in more detail laterStores relational databasesResponds to queries in language called SQL
![Page 7: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/7.jpg)
Tiered archtiecturesAn example of separation of concerns.Most popular model has three layersDeveloped for maintenance reasons
![Page 8: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/8.jpg)
Three-tier model
Business objects
Business objects DatabaseDatabase
Clients
Presentation layer Processing layer Data layer
![Page 9: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/9.jpg)
Three tiersPresentation layer contains HCI for clientProcessing layer contains business objectsData layer contains some stored data
![Page 10: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/10.jpg)
RationaleHCI can go on the client and does not require to be transmitted over networkBusiness objects reflect domain entitiesBusiness objects shield the implementation of data
![Page 11: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/11.jpg)
Business objectsReflect entities in application, for example in a sales site: catalogue, product and customerAll application programming done on business objectsDetails of underlying data hidden to the application programmer, for example the programmer should be unaware of the database technology
![Page 12: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/12.jpg)
Database Servers
![Page 13: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/13.jpg)
Database serversHave been in existence for some time.Described here as they play a major part in ecommerce systemsVirtually all based on the relational model
![Page 14: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/14.jpg)
Relational tables
ItemId Item NoInStock
Aw222 Washer A 300
Ntr444 Nut A 2009
Edt666 Spanner S 802
Bt555qw Bolt B 200
KeyEach row contains associated data
![Page 15: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/15.jpg)
SQLStructured Query LanguageIn existence for many yearsUsed to create, modify and retrieve data from relational tablesNo standardised
![Page 16: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/16.jpg)
An example
Select EmployeeName, Salary From Employees WHERE Salary>3500
Names of columns
Name of table
Condition
![Page 17: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/17.jpg)
Typical configuration
Web server Databaseserver
Clients
![Page 18: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/18.jpg)
Functions of a database server
Interpret SQL statements and execute themOptimise queriesTo prevent concurrency errorsTo detect deadlockTo administer securityTo administer backup
![Page 19: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/19.jpg)
Stored proceduresSnippets of ‘compiled’ code which are equivalent to subroutinesStored at serverEfficient alternative to sending large numbers of SQL statements over communication media
![Page 20: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/20.jpg)
Stored procedures: for and against
PlusMore efficient in processing timeReduces network trafficKeeps database code close to the database
MinusThey are non-standardOptimisation needs to be repeated as access strategies to a database change
![Page 21: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/21.jpg)
Referential integrityTables in a relational database are consistent with each otherAssociated with business rulesTwo ways of implementing it: declarative referential integrity and trigger-based referential integrity
![Page 22: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/22.jpg)
ImplementationDeclarative referential integrity is maintained by declarations in database schemasTrigger based referential integrity is achieved by embedding code
![Page 23: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/23.jpg)
Pros and consTrigger based
Non-standardTriggers found scattered throughout a systemSome implementations have upper limit to number of triggers
Declaration basedSelf-documentingStandard
![Page 24: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/24.jpg)
Relational middleware
Serversoftware
Serversoftware
Clients
DatabaseDatabase
SQL API
Driver
Stacks
![Page 25: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/25.jpg)
The componentsThe API provides programmer facilitiesThe driver communicates SQL statements to the server softwareThe stack contains protocol softwareServer software carries out the main functions, for example executing SQL queries
![Page 26: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/26.jpg)
Distributed databases
Databases spread around servers in a distributed systemDatabases distributed for performance reasons: keeping data close to clientsDistributed for reliability using replicated dataDistributed because of legacy: many systems have evolved from separate systems
![Page 27: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/27.jpg)
Problems with distributed data
Keeping replicated data up-to-dateEnsuring concurrent access keeps a database in its correct stateSecurity is a big headacheReliability is a problemClock synchronisation is a problem
![Page 28: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/28.jpg)
Types of distributionDownloading: periodically writing data to a remote databaseData replication: keeping identical sets of data in stepFragmentation: splitting data into sub-tables.
![Page 29: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/29.jpg)
FragmentationHorizontal fragmentation, splitting tables lengthways - split tables have the same columns as original tableVertical fragmentation, where the split tables are associated with a subset of the columns of the original table
![Page 30: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/30.jpg)
Java as a medium for database development (i)Driver, used for database driversStatement, an SQL statementPreparedStatement, ‘compiled SQL statements’CallableStatement, stored procedure
![Page 31: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/31.jpg)
Java as a medium for database development (ii)Connection, facilities for connecting to a databaseResultSet, collection of data retrieved from a queryDatabaseMetaData, data about a databaseDriverManager, manages connections to a database
![Page 32: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/32.jpg)
Developing Java code to access a database
Load a driverEstablish a database connectionAssociate an SQL statement with this connectionExecute the statementProcess a result setClose the connection
![Page 33: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/33.jpg)
Loading the driver //Set the name of the file that is to be accessed
//and the name of the driverString fileURL = “...”;String driverName = “...”;try{ // Load in the driver programmatically
Class.forName(driverName);}catch (ClassNotFoundException cfn){
//Problem with driver, display error message and //return to operating system with status value 1 System.out.println(“Problem loading driver”); System.exit(1);}
![Page 34: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/34.jpg)
Establishing a connection
try{ //Establish a connection to the database, second //argument is the name of the user and the third //argument is a password (blank) Connection con = DriverManager.getConnection(fileURL, “Darrel”,””);
![Page 35: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/35.jpg)
Create and execute an SQL statement
// Create a statement objectStatement selectStatement = con.createStatement();// Execute the SQL select statementResultSet rs = selectStatement.executeQuery (“SELECT name, salary FROM employees WHERE salary >35000");
![Page 36: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/36.jpg)
Process the result set
String employeeName;int employeeSalary;while(rs.next()){ employeeName = rs.getString(1); employeeSalary = rs.getInt(2); System.out.println(“Name = “+ employeeName + “Salary = “+ employeeSalary);}
![Page 37: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/37.jpg)
Close down connections
//Close down the database connection, result set//and the SELECT statementselectStatement.close();con.close();rs.close();
![Page 38: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/38.jpg)
Meta dataData about dataCan be data about a database, a result set or a driverJava contains classes which enable such data to be easily extracted
![Page 39: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/39.jpg)
An example
Connection c;// Code to establish a connectionDatabaseMetaData dmd = c.getMetaData();System.out.println(“Driver is ”+ dmd.getDriverName() +
“ Version number = “+dmd.getDriverVersion());
Obtaining data about the driver: its name and version number
![Page 40: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/40.jpg)
Three tier with relational database
Clients
Businessobjects
Relationaldatabases
Mapping
![Page 41: Clients and Server. Clients and servers A server provides a service such as dispensing files. A client calls on a service. The distinction is not hard](https://reader035.vdocuments.us/reader035/viewer/2022062312/5515c803550346a3758b49ba/html5/thumbnails/41.jpg)
Mappings
Classes usually mapped to tablesInstance variables to columnsRelationships to common data in tables