Presentation is loading. Please wait.

Presentation is loading. Please wait.

6/25/20151 Introduction to Database Systems zPurpose of Database Systems zViews of Data zData Models zData Definition Language zData Manipulation Language.

Similar presentations


Presentation on theme: "6/25/20151 Introduction to Database Systems zPurpose of Database Systems zViews of Data zData Models zData Definition Language zData Manipulation Language."— Presentation transcript:

1 6/25/20151 Introduction to Database Systems zPurpose of Database Systems zViews of Data zData Models zData Definition Language zData Manipulation Language zTransaction Management zStorage Management zDatabase Administrator zDatabase Users zOverall System Structure

2 6/25/20152 Database Management System (DBMS) zCollection of interrelated data zSet of programs to access the data zDBMS contains information about a particular enterprise zDBMS provides an environment that is both convenient and efficient to use.

3 6/25/20153 Purpose of Database Systems zDifficulties in conventional file-processing systems: (DBMS attempts to solve) yData redundancy and inconsistency yDifficulty in accessing data yData isolation -- multiple files and formats yIntegrity problems yAtomicity of updates yConcurrent access by multiple users ySecurity problems

4 6/25/20154 View of Data …... View level View 1View 2View n Logical level Physical level

5 6/25/20155 Levels of Abstraction zPhysical level: describes how a record (eg.: customer) is stored in terms of block#, sector#, byte# etc. zLogical level: describes data stored in database, and the relationship among the data: customer { string name; string street; integer city; } zView level: Application programs/GUI etc hide the actual representation and present only the required data in a convenient way. Eg: Visual forms, graphical forms.

6 6/25/20156 Instances and Schemas zSchema is a description and an instance is a set of data that fits the description. zSchema : logical structure of the database (eg. Set of customers and accounts and the relationship between them) zInstance : actual content of the database at a particular point in time. zOne schema may have many instances. zAnalogy : type and variable in a programming language.

7 6/25/20157 Data Independence zAbility to modify a schema definition in one level without affecting a scheme definition in the next higher level. zInterfaces between the various levels and components should be well defined so that changes in some parts do not seriously influence others: zTwo levels of data independence: yPhysical data independence yLogical data independence

8 6/25/20158 Data Models zA collection of representations for describing: ydata, data relationships, data semantics, data constraints zObject-based logical models yEntity-Relationship (ER) model yObject-oriented model ySemantic model yFunctional model zRecord-based logical models yRelational model (e.g. SQL/DS, DB2) yNetwork model yHierarchical Model yObject relational model

9 6/25/20159 Entity-Relationship Model customer name SSN street city account number balance depositor entity attribute relationship

10 6/25/201510 Relational Model NameSSNstreetcityaccount no. Johnson 192-83-7465Alma Palo AltoA-101 Customer Table Account No.Balance Account Table A-101 500

11 6/25/201511 Data Definition Language (DDL) zSpecification notation for defining database scheme zDDL compiler generates a set of tables in a data dictionary zData dictionary contains metadata (data about data) zData storage and definition language - special type of DDL in which storage and access methods used by the dbms are specified. zSQL create, define tables

12 6/25/201512 Data Manipulation Language zLanguage for accessing and manipulating the data organized by appropriate data model zTwo classes of languages: yProcedural - user specifies what data is required and how to get those data yNon-procedural -- user specifies what data is required without specifying how to get those data zQuery language (sequential query language: sql) : insert data, update data

13 Relational Algebra zTables representing relations zRow uniquely identified by a primary key zRelated tables are associated using foreign keys zSpecial operators are defined and axioms: join, project etc.: relational algebra zhttp://db.grussell.org/section010.htmlhttp://db.grussell.org/section010.html 6/25/201513

14 6/25/201514 Transaction Management zA transaction is a collection of operations that perform a single logical function in a database application zExample: Withdraw $100 from Acct Number A-101 yVerify the balance yUpdate account table (& other tables) yDeliver money

15 6/25/201515 Transaction Management (contd.) zTransaction-management component ensures that the db remains in a correct state despite system failures (e.g. power failures and operating system crashes) and transaction failures. zACID property: Atomicity, Consistency, Isolation, Durability zConcurrency-control manager controls the interaction among the concurrent transactions.

16 6/25/201516 Storage Management zA storage manager provides the interface between the low-level data and the application programs and queries submitted to the system. zThe storage manager is responsible for the following tasks: yinteraction with file-manager yefficient storing, retrieving, and updating of data

17 6/25/201517 Overall System Model Naïve usersApplication programmers Sophisticated users DBA Application interfaces Application programs query Database scheme Query processing DBMS System Object code Embedded DML compiler DML compiler DDL interpreter Query evaluation engine Storage manager Transaction manager Buffer manager File manager Data dictionary Statistical data indices Data files Disk storage

18 6/25/201518 Database Administrator zCoordinates all the activities of the database system; zDBA should have a good understanding of the enterprise’s information resources and needs. zDBA’s duties include: yScheme definition yStorage structure and access method definition yGranting user authority to access the database ySpecifying integrity constraints yActing as liaison with users yMonitoring performance and responding to changes in requirements

19 6/25/201519 Database Users zDifferentiated by the how they interact with the system zNaïve users: invoke pre-determined application with high-level user interface zApplication programmers; Use DML calls, embedded calls zSophisticated users: managers, decision support systems: request using query languages zSpecialized users: design and write specialized applications.

20 Links/support zhttps://wiki.cse.buffalo.edu/services/content/how-use-jdbc-oraclehttps://wiki.cse.buffalo.edu/services/content/how-use-jdbc-oracle 6/25/201520

21 6/25/2015B.Ramamurthy21 Simple Database Application APPLICATIONAPPLICATION DBMSDB Ex: Access Oracle MySql

22 6/25/2015B.Ramamurthy22 Multi-Databases APPLICATIONAPPLICATION DBMS 1 DBMS 2 DBMS 3 DB

23 6/25/2015B.Ramamurthy23 Standard Access to DB APPLICATIONAPPLICATION DRIVERMGRDRIVERMGR DBMS Driver 1 DBMS Driver 2 DBMS Driver 3 DBMS 1 DBMS 2 DBMS 3 DB

24 6/25/2015B.Ramamurthy24 ODBC Architecture Application Class1Class2 Driver Manager DriverType1DriverType2DriverType3 DataSource2 DataSource1 DataSource3 ODBC

25 6/25/2015B.Ramamurthy25 Open Database Connectivity (ODBC) Standard z ODBC standard is an interface by which application programs can access and process SQL databases in a DBMS-independent manner. It contains: z A Data Source that is the database, its associated DBMS, operating system and network platform z A DBMS Driver that is supplied by the DBMS vendor or independent software companies z A Driver Manager that is supplied by the vendor of the O/S platform where the application is running

26 6/25/2015B.Ramamurthy26 ODBC Interface zIt is a system independent interface to database environment that requires an ODBC driver to be provided for each database system from which you want to manipulate data. zThe database driver bridges the differences between your underlying system calls and the ODBC interface functionality.

27 6/25/2015B.Ramamurthy27 An Example ApplicationDriverManager DB2 driverMYSQL driverOracle driver odbc standard API

28 6/25/2015B.Ramamurthy28 Application in Java Application in Java DriverManager Access driverMYSQL driverOracle driver odbc standard API jdbc API

29 6/25/2015B.Ramamurthy29 Java Support for ODBC : JDBC zWhen applications written in Java want to access data sources, they use classes and associated methods provided by Java DBC (JDBC) API. zJDBC is specified an an “interface”. zAn interface in Java can have many “implementations”. zSo it provides a convenient way to realize many “drivers”

30 6/25/2015B.Ramamurthy30 Java Support for SQL zJava supports embedded SQL. zAlso it provides an JDBC API as a standard way to connect to common relational databases. zYou need a JDBC:ODBC bridge for using the embedded SQL in Java. zJava.sql package and an extensive exception hierarchy. zWe will examine incorporating this bridge using sample code.

31 6/25/2015B.Ramamurthy31 Data Source zLocal relational database; Ex: Oracle zRemote relational database on a server; Ex: SQLserver zOn-line information service; Ex: Dow Jones, Customer database

32 6/25/2015B.Ramamurthy32 Data Source and Driver zData source is the data base created using any of the common database applications available. zYour system should have the driver for the database you will be using. zFor example your Windows system should have the MS Access Driver. zThere are a number of JDBC drivers available. zOn the IDE you are using you will install the appropriate driver.

33 6/25/2015B.Ramamurthy33 JDBC Components zDriver Manager: Loads database drivers, and manages the connection between application & driver. zDriver: Translates API calls to operations for a specific data source. zConnection: A session between an application and a driver. zStatement: A SQL statement to perform a query or an update operation. zMetadata: Information about the returned data, driver and the database. zResult Set : Logical set of columns and rows returned by executing a statement.

34 6/25/2015B.Ramamurthy34 JDBC Classes zJava supports DB facilities by providing classes and interfaces for its components zDriverManager class zConnection interface (abstract class) zStatement interface (to be instantiated with values from the actual SQL statement) zResultSet interface

35 6/25/2015B.Ramamurthy35 Driver Manager Class zProvides static, “factory” methods for creating objects implementing the connection interface. yFactory methods create objects on demand zwhen a connection is needed to a DB driver, DriverManager does it using it factory methods.

36 6/25/2015B.Ramamurthy36 Connection interface zConnection class represents a session with a specific data source. zConnection object establishes connection to a data source, allocates statement objects, which define and execute SQL statements. zConnection can also get info (metadata) about the data source.

37 6/25/2015B.Ramamurthy37 Statement interface zStatement interface is implemented by the connection object. zStatement object provides the workspace for SQL query, executing it, and retrieving returned data. zSELECT {what} FROM {table name} WHERE {criteria} ORDER BY {field} zQueries are embedded as strings in a Statement object. zTypes: Statement, PreparedStatement, CallableStatement

38 6/25/2015B.Ramamurthy38 ResultSet interface zResults are returned in the form of an object implementing the ResultSet interface. zYou may extract individual columns, rows or cell from the ResultSet using the metadata.

39 6/25/2015B.Ramamurthy39 JDBC Application Architecture Application Connection Driver Manager Driver DataSource Statement Result Set

40 6/25/2015B.Ramamurthy40 JDBC Programming Steps zImport necessary packages; Ex: import java.sql.*; zLoad JDBC driver(driver should have been installed) zData source and its location should have been registered. zAllocate Connection object, Statement object and ResultSet object zExecute query using Statement object zRetrieve data from ResultSet object zClose Connection object.

41 6/25/2015B.Ramamurthy41 Identifying Data Sources zIt is specified using URL format. z : : Example(for local source): jdbc:odbc:tech_books zAlternatively, for remote connection, jdbc:odbc://bina.cse.buffalo.edu:4333/tech_books

42 Summary zWe learned the inner details of the relational database model z We also studied methods for programmatically accessing the data sources from Java language zThis is just one persistence model. zWe will revisit data/storage later on in the semester in the “big-data” context. 6/25/201542


Download ppt "6/25/20151 Introduction to Database Systems zPurpose of Database Systems zViews of Data zData Models zData Definition Language zData Manipulation Language."

Similar presentations


Ads by Google