Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Entity–attribute–value model wikipedia , lookup
Concurrency control wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Microsoft SQL Server wikipedia , lookup
Open Database Connectivity wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Relational model wikipedia , lookup
Functional Database Model wikipedia , lookup
Versant Object Database wikipedia , lookup
ContactPoint wikipedia , lookup
The Application Model A logical network of cooperative, distributed, and reusable services that support a business solution. User Services Business Services Data Services The Services-Based Application Model The term service-based means that the functionality of an application is specified as collections of services that meet specific user need. A service-based application application is typically comprised of three categories: user services, business services and data service. User services Business services Data services Computer Information storage and manipulation Internet Intranet Rules, Transactions Database User services provide an application with its user interface. The user of a service can be a person or another service. Therefore, the interface for a service can provide a graphical user interface or a programmatic interface. Business services enforce business rules and handle transactions. These services may impose constraints or apply transformations to change user input or raw database information into usable business information. Data services provide storage and low-level manipulation of data in a database. Examples of data services include create, read, update and delete, which are used by business services to modify a database. A business service does not need to know where data is located, how it is implemented, or how it is accessed. These tasks are handled by data services. Data Services Provide storage and low-level manipulation of data in a database. Examples of data services include create, read, update and delete, which are used by business services to modify a database. A business service does not need to know where data is located, how it is implemented, or how it is accessed. These tasks are handled by data services. ODBC Driver Database OLE DB Provider Standard middle-ware such as Open Database Connectivity (ODBC), have been developed for interfacing of clients wit servers. ODBC is an application program interface that allows clients to generate SQL statements that are sent to a server. Any client that uses the ODBC interface can connect to any server that provides the interface. In earlier-generation database systems, the lack of such standards necessitated that the front-end and the back-end be provided by the same software vendor. Application Models Over the past few decades, the architecture of applications, especially large enterprise, have evolved from single-tier to n-tier designs. The driving force for this change has been the following general goals: scalability, separation and encapsulation of functionality, maintainability, multi-user support, and the ability to be distributed. Understanding Service Tiers Tiers are a logical concept that provide a way to describe how applications can be segmented into services, specially the three types of services : user, business and data. Single-Tier Applications A single-tier application is simply a monolithic, stand-alone program that runs on the user’s computer. It may communicate with a database, but that database resides on the same computer physical logical User services Business services Data services Two-Tier Client/Server Applications The simplest type of distributed computing is the two-tier client/server application. In this type of application, the database is separated from the user interface and business logic. Typically the database is placed on the other server. Two-tier client/server applications are the most common type of client/server applications built today. They offer significant benefits over single-tier applications because data processing is centralized and becomes a shared resource among potentially many users. User services Business services Database Server Database server Data services Three-Tier Client/Server Applications Over time it has become apparent that the two-tier client/server model is simply not flexible or powerful (scalable) enough to to handle many larger applications. Maintaining a dialog between each client workstation and the central database server can result in high network traffic and poor performance, for example when many users try to do simultaneous access to a database. Three-tier server applications help address these issues by putting another layer between the users and the database the application server Physical User services Business services Application server Database Server Database server Data services N-Tier Client/Server Applications (Web-Based Applications) The two and three tier application models leave a substantial part of the application on the client workstation. Conversely, applications designed for the World Wide Web place as little of the application as possible on the client, and keep all the processing centralized on one or more servers. Physical User services Internet/Intranet Web services Web server Business services Application server Database Server Database server Data services Logical Network of Cooperating Services Application 1 User Services Business Services Data Services Application 2 Multitier Application Architecture with Distributed Transactions J2EE System Environment สรุ ป Benefits of Services-Based Design • • • • Added flexibility Distributed services Parallelism in the design process Shared assets, resources, and skills ื่ มต่อ ระบบฐานข ้อมูลและการเชอ Data Store and Data Services • Separates business services from the application’s data store. • Provides basic create, retrieve , update and delete capabilities. •Performs data aggregation. • Provides data integrity. User Interface User Services Business Services Data Services Data Store สถาปัตยกรรมระบบ Application server : สว่ นการจัดการ ้ Dynamic Link Library เพือ ่ ใชในการ ประมวลผลตาม business Logic ต่างๆ ของระบบงาน 3-Tiers Client/Server application ้ ั่ เหมาะสาหรับองค์กรทีม ่ ผ ี ู ้ใชแอพพลิ เคชน จานวนมาก โดยใช ้ Database server หนึง่ ้ server หรือมากกว่า และต ้องการให ้ใชงาน ได ้ทัง้ ในระบบ LAN, WAN หรือ Internet ข ้อได ้เปรียบข ้อสถาปั ตยกรรม ได ้แก่ ิ ธิภาพ ความยือหยุน ประสท ่ ในการรองรับ ้ จานวนผู ้ใชมากๆและเพิ ม ่ ขึน ้ การจัดการ และการดูแลระบบทาได ้ง่าย (ถ ้าเป็ น web application) ไม่มก ี ารติดตัง้ business logic ้ กับเครือ ่ งลูกข่าย และนาโค ้ดกลับมาใชใหม่ ได ้ง่าย ี คือยากในการออกแบบ รายละเอียดมาก ข ้อเสย ้ ใชงบประมาณ และเวลามาก และผู ้พัฒนา ต ้องมีความชานาญ ้ Com Component (.dll) เป็ นซอฟท์แวร์ทใี่ ชในการเก็ บรวบรวม COM Component (.dll) ต่าง ๆ ทีไ่ ด ้ทาการพัฒนาขึน ้ โดยทาการเก็บอยูใ่ นเครือ ่ งทีเ่ ป็ นแม่ขา่ ย เพือ ่ ให ้เป็ นศูนย์รวมของการประมวลผล ตาม business logic ต่าง ๆ นอกจากนัน ้ ยังเป็ นตัวชว่ ยในการทาแคชของการประมวลผลต่าง ๆ เพือ ่ ให ้ ้ ้ ้อม ๆ กันได ้มากขึน สามารถรองรับการใชงานของผู ้ใชพร ้ จึงสง่ ผลให ้การทางานของตัวระบบงานยังคง ิ ธิภาพเชน ่ เดิมถึงแม ้ว่าจะมีผู ้ใชที ้ เ่ พิม มีประสท ่ มากขึน ้ ก็ตาม เนือ ่ งจากเป็ นการแยกสว่ นกันของการ ่ ารลดปั ญหาคอขวดของเครือข่ายได ้ ระมวลผลระหว่างเครือ ่ งลูกข่ายและเครือ ่ งแม่ขา่ ยจึงนาไปสูก Stored Procedures การประมวลผลเมือ ่ มีการใช ้ query เพือ ่ ค ้นหาข ้อมูลนัน ้ จะต ้องมี การแปลคาสงั่ ต่าง ๆ ตามไวยกรณ์ทก ุ ครัง้ ทีม ่ ก ี ารรัน query แต่หาก ได ้มีการนา queries เหล่านัน ้ มาสร ้างเป็ น Store Procedures ซงึ่ ้ เป็ น object ตัวหนึง่ ของฐานข ้อมูล โดยก่อนการใชงาน ระบบจะทา การ compile เพือ ่ โหลดเข ้าไปยัง cache memory (server side) ี ก่อน เป็ นผลให ้สามารถทางานได ้อย่างรวดเร็ว และมีประสท ิ ธิภาพ เสย ทีด ่ ก ี ว่าการ Query ธรรมดามาก The first time the stored procedure is executed, a query execution plan is created and compiled. The compiled plan stays in memory on the server until it is forced out by other memory needs. This means that subsequent calls to the stored procedure result is much better performance than re-creating the same SQL command each time it is needed. ข้อดีของ Stored Procedures ั ซอนซ ้ • สามารถทางานทีซ ่ บ งึ่ ไม่สามารถกระทาจาก transact-SQL โดยตรงได ้ ิ ธิภาพในการใชงาน ้ • ชว่ ยเพิม ่ ประสท เนือ ่ งจากได ้มีการคอมไพล์กอ ่ น การใช ้ และในครัง้ แรกของการรัน จะมีการเตรียม query execution plan เพือ ่ โหลดคาสงั่ ต่าง ๆ ไปยัง cache memory ชว่ ยให ้การ งานรวดเร็วยิง่ ขึน ้ ้ • ชว่ ยลดจราจลบนระบบเน็ ตเวิรค ์ เพราะเป็ นการเรียกใชงานชุ ดคาสงั่ ่ ไม่ให ้มี user • ชว่ ยในเรือ ่ งกลไกของระบบรักษาความปลอดภัย เชน ิ ธิให ้ ใดสามารถเข ้าถึงข ้อมูลจากตารางโดยตรงได ้ แต่จะกาหนดสท สามารถรัน stored procedure เพือ ่ แก ้ไขข ้อมูลในตารางตามที่ กาหนดไว ้ได ้แทน เป็ นต ้น • Accept parameters. • Return values of parameters to a calling procedure or client. • Return a status value that indicates success or failure, as well as the reason for the failure. • Call other stored procedures. • Encapsulate business functionality so that all applications can use and perform the procedures consistently. • Make execution faster and more efficient. Once they are compiled no syntax checking is required when they are executed. • Store the compiled version on the server and use it for subsequent calls, thus reducing network traffic. • Be called from different client applications. รูจ ้ ัก Batch Batch คือกลุม ่ คาสงั่ ของ transact-SQL ซงึ่ จะถูกแปลความไป ่ พร ้อมกัน เชน Use Engineer Select stuID, stuName, stuAVG From student Insert student (stuID, stuName, stuAVG) values (46507912, Jittas, 3.89) Select lecture.lectID, lectName, Subject_code from lecturer,subject where lecture.lectID = subject.lectID GO ประเภทของ Stored Procedures Stored Procedures แบ่งออกเป็ น System Stored Procedure, และ User Stored Procedures CREATE PROCEDURE up_Suppliers AS Select CompanyName, ContactName, ContacTitle FROM Suppliers ORDER BY CompanyName clsUsers clsBhd12RL Bhd12RL clsPosMoney PosMoney clsSpeAddAll SpeAddAll clsNewRateGetID clsBhd12RL - - Bhd12RL clsSpeAddAll SpeAddAll clsPosMoney PosMoney Deployment Diagrams Client Application Server dllSalaryList Printer dllSalaryList Database Server The Component of data Bit Byte Word Field Record File Database 0 or 1 1 byte is constructed from 8 bits to represent 1 character. 1 word is constructed from 2 or more consecutive bytes column boundary of specific data relation of the value in each field to represent one object (or one thing or one person) A collection of several records of the same type. A collection of interrelated data files. File Processing & Database Processing File Processing Salary Information System Salary Files Personal Information System Personal Files Seminar Information System Seminar Files Database Management System Salary Information System Personal Information System Seminar Information System DBMS Data Base DBMS: Database Management System DBMS consists of a collection of interrelated data and a set of programs to access those data. The primary goal of DBMS is to provide an environment that is both convenient and efficient to use in retrieving and storing database information. DBMS acts as the interface software between users and data stored in the database by hiding the detail of internal สถาปัตยกรรมของระบบฐานข้ อมูล External View 1 External View 2 Conceptual Level Physical Level External View 3 Billing Application Load Research Application Billing & Research Data Model Maintenance Application Maintenance Data Model Information Services Data Model Database Management System Service Databases Logical User Views Data elements and relationships needed for Billing, Load Research, or Maintenance processing Data elements and relationships (the schema) needed for the support of all information services. Software Interface The DBMS provides access to the information services databases Physical Data Views Organization and location of data on the storage media. Instance และ Schema Instance ของฐานข้ อมูล : เหล่าข้ อมูลทีถ่ ูกจัดเก็บในฐานข้ อมูล ในขณะใดขณะหนึ่ง ดังนั้น Instance จึงเปรียบเสมือนกับค่ าของตัว แปรในขณะใดขณะหนึ่งใน Programming Language การ เปลีย่ นแปลงข้ อมูลในระบบฐานข้ อมูล มีสาเหตุมาจากการทีข่ ้ อมูลมีการ Insert, Delete หรื อ Update เกิดขึน้ ตลอดเวลา Schema : เค้าร่ าง (โครงสร้ าง) ทีไ่ ด้ จากการออกแบบฐานข้ อมูล โดยรวม เช่ นการกาหนดว่ า ระบบฐานข้ อมูลควรประกอบด้ วย ไฟล์อะไรบ้ าง และไฟล์เหล่านั้นมีความสั มพันธ์ กนั อย่ างไร แต่ ละไฟล์ ควรประกอบด้ วยฟิ ลด์ (fields) อะไรบ้ าง Data Definition Language (DDL) การทีจ่ ะกาหนดเค้ าโครง หรื อ Scheme ของฐานข้ อมูล สามารถ กระทาได้ โดยการใช้ ภาษาพิเศษ ทีเ่ รียกว่ า ภาษาสาหรับนิยามข้ อมูล ตัวอย่ าง ภาษา DDL CREATE TABLE ALTER TABLE DROP TABLE เช่ น CREATE VIEW CREATE INDEX DROP VIEW DROP INDEX CREATE TABLE S ( S# Char(5) Not Null, Sname Char(20) Not Null, Status SmallInt Not Null, City Char(15) Not Null, PRIMARY KEY (S#) ); ผลจากการคอมไพล์ ประโยคทีเ่ ขียนด้ วย DDL (DDL Interpreter) จะทาให้ เกิดตารางทีจ่ ะจัดเก็บในไฟล์ ชนิดหนึ่งทีเ่ รียกว่ า พจนานุกรม ข้ อมูล (Data Dictionary) ซึ่งเก็บข้ อมูลทีเ่ กีย่ วกับ โครงสร้ างทีไ่ ด้ จากการออกแบบ ฐานข้ อมูลนั้น ๆ และถ้ ามีการเปลีย่ นแปลงแก้ไข หรื อ เรียกใช้ ข้อมูล DBMS ต้ องอาศัยข้ อมูลของโครงสร้ างจากไฟล์ นีเ้ สมอ Data Manipulation Language (DML) การใช้ ข้อมูลในระบบฐานข้ อมูล อาจจาแนกได้ เป็ น - การเรียกดูข้อมูล (RetrieveData) - การเพิม่ ข้ อมูลใหม่ (Insert Records) - การลบข้ อมูลเดิม (Delete Records) - การเปลีย่ นแปลงแก้ ไขข้ อมูลเดิม (Update Fields) การใช้ ข้อมูลในระดับของผู้ใช้ น้ัน สามารถกระทาได้ โดยผ่ านทาง DBMS ซึ่งได้ เตรีมภาษาสาหรับการใช้ ข้อมูล (DML is a language that enables users to access or manipulate data as ornagized by the appropriate data model.) การเขียนแอปพลิเคชั่นด้ วย Host Language เพื่อร้ องขอ (request) ข้ อมูลจากระบบฐานข้ อมูล ทาได้ โดยการใช้ คาสั่ ง DML ภายใน Host Language นั้น แต่ เนื่องจาก DML Syntax แตกต่ างไปจาก Syntax ของ Host Language ทัว่ ไป ดังนั้นโปรแกรมจัดการระบบฐานข้ อมูล (DBMS) จึงต้ องมี Query Processor ซึ่งประกอบด้ วย Embedded DML Precompiler DML Compiler Query Evaluation Engine DDL Interpreter Embedded DML Precompiler : แปลง (convert) ประโยคคาสั่ ง DML ให้ เป็ นโมดุลหนึ่ง (procedure call) ภายในแอ็ปพลิเคชั่นที่สร้ างด้ วย host language ภาษาใด ภาษาหนึ่ง ซึ่งมีผลทาให้ แอ็ปพลิเคชั่น สามารถถูก Compile ได้ ด้ วยตัว Compiler ปกติของภาษานั้น และสามารถ ประมวลผล object ของ Database (เช่ น object ทีเ่ ป็ น relation) ได้ DML Compiler : แปล (translate) ประโยคคาสั่ ง DML ไปเป็ น low-level instructions ที่ Query Evaluation Engine สามารถเข้ าใจได้ Embedded DML Precompiler ต้ องติดต่ อกับ DML Compiler เพื่อ สร้ าง Object Code ทีเ่ หมาะสม DDL Interpreter : แปลประโยคคาสั่ งที่เขียนด้ วย DDL Query Evaluation Engine : เมื่อ DML Compiler สร้ าง Object Code ทีเ่ ป็ น Low-level Instructions ขึน้ มาแล้ว ก็จะส่ งต่ อให้ กบั Query Evaluation Engine ทาการประมวลผลต่ อไป Data Consumers Visual Basic Application Visual C++ Application ASP page Other Applications ADO Connection Service Components Cursor Engine Data Providers ODBC Provider ODBC Database Server DML Compiler DDL Interpreter Embedded DML Precompiler Query Evaluation Engine Query Processor Simple Data Provider Mainframe Data Non Relation Data How Database Represent Information A database management system (DBMS) is a combination of software and data: • The physical database : a collection of files that contain the data content. •The schema: a specification of the information content of the physical database •The database engine: software that supports access to and modification of the contents of the database •The data definition and manipulation language: programming languages that support schema definition and database access. Overall System Structure Query processor components • DML compiler • Embedded DML precompiler • DDL interpreter • Query evaluation engine Storage manager components : provides the interface between the low level data stored in the database and the application programs and queries submitted to the system • Authorization and integrity manager : tests for the satisfaction of integrity constraints and checks the authority of users to access data. • Transaction manager : ensures that the database remains in a consistent state despite system failures and that concurrent transaction executions proceed without conflicting. • File manager : manages the allocation of space on disk storage and the data structures used to represent information stored on disk. • Buffer manager : responsible for fetching data from disk storage into main memory. • Data files : store the database itself. •Data dictionary : stores metadata about the structure of the database. The data dictionary is used heavily. Therefore, great emphasis should be placed on developing a good design and efficient implementation of the dictionary. • Indices : provide fast access to data items that hold particular values. Naïve users use Application programmers write Application interfaces Sophisticated users Database administrator use use Application programs Application programs object code Transaction manager database scheme query Embedded DML precompiler DML compiler Query evaluation engine File manager Data files Buffer manager Indices users DDL interpreter Authorization and integrity manager Data dictionary query procesor Storage manager Disk storage Database Processing Advantages Data redundancy (Repetition of data) can be reduced. Data inconsistency can be avoided. Data can be shared. Standard of data can be controlled. Concurrent-access to database can be provided. Data Integrity and data security can be maintained.