<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss'><id>tag:blogger.com,1999:blog-34158316</id><updated>2009-02-21T04:08:09.519-08:00</updated><title type='text'>linda</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://lindaahmed.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34158316/posts/default'/><link rel='alternate' type='text/html' href='http://lindaahmed.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>linda</name><uri>http://www.blogger.com/profile/12538669834728464262</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-34158316.post-115817940309752582</id><published>2006-09-13T12:40:00.000-07:00</published><updated>2006-09-13T13:30:03.186-07:00</updated><title type='text'></title><content type='html'>&lt;a href="http://data"&gt;http://data base secuirty&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;1&lt;br /&gt;THE NEED FOR SYSTEMS SECURITY&lt;br /&gt;The opening of mission-critical systems to partners and customers over the Internet poses new&lt;br /&gt;challenges to traditional notions of enterprise security. Data access must now be controlled at a very&lt;br /&gt;fine level of granularity, often to the level of individual customers or users. Organizations providing&lt;br /&gt;"hosting" environments seek to deploy common applications which nonetheless can incorporate&lt;br /&gt;customer-specific preferences, and operate on customer-specific data. Oracle8i addresses these&lt;br /&gt;requirements by providing highly granular, server-enforced access control and flexible privilege models.&lt;br /&gt;Users can be strongly authenticated, even remotely, and data is protected in transit by network&lt;br /&gt;encryption. Oracle8i enforces the same strong security whether users access data directly, or through&lt;br /&gt;middle tiers, such as application servers or transaction processing (TP) monitors.&lt;br /&gt;Another challenge of system security is ease of management. Organizations spend significant time and&lt;br /&gt;resources managing multiple user accounts and privileges. Additionally, they often must implement&lt;br /&gt;security in multiple applications accessing the same data ¾ which is duplicative and often leads to&lt;br /&gt;security vulnerabilities ¾ instead of building security once, in the data server. Security is often&lt;br /&gt;complex and expensive to implement. Oracle8i addresses these needs by offering integrated security&lt;br /&gt;and directory services, which enables Public Key Infrastructure (PKI)-based single sign-on. Single&lt;br /&gt;Station Administration allows organizations to manage users and their privileges centrally, with greater&lt;br /&gt;ease and lower cost. Flexible, granular security can be built once in the data server, instead of in&lt;br /&gt;multiple applications, and business logic may be divorced from actual privileges and data, which means&lt;br /&gt;that applications can be developed once, then reused and redeployed at significant cost savings.&lt;br /&gt;Within the enterprise, information is stored on physically separate computers in different locations.&lt;br /&gt;Therefore, it is essential that users be able to access all information easily and consistently.&lt;br /&gt;Consequently, a database server must provide the technology to hide the complexity of data access from&lt;br /&gt;users, allowing them to access distributed information as if it were all stored on the same computer.&lt;br /&gt;Oracle8i addresses this requirement by providing a transparent interface to all data in the system,&lt;br /&gt;improving access to information and simplifying application development.&lt;br /&gt;Oracle8i addresses all these security and functionality needs by providing complete and robust facilities&lt;br /&gt;for managing data and implementing a strong, yet flexible, security policy. This paper describes these&lt;br /&gt;security facilities, and how an organization can use them to enforce an overall security policy&lt;br /&gt;throughout Oracle8i.&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;2&lt;br /&gt;SECURITY CONCEPTS&lt;br /&gt;Basic computer security concepts require that an information system be able to identify and control&lt;br /&gt;critical aspects such as:&lt;br /&gt;· Who the authorized users are (identification and authentication).&lt;br /&gt;· What users should have access to (object access controls).&lt;br /&gt;· What types of operations users can perform on those objects (also part of object access control).&lt;br /&gt;· What types of activities have occurred (e.g., the ability to maintain accountability via auditing).&lt;br /&gt;· Extended security concepts further address issues such as data and system integrity, reliability and&lt;br /&gt;availability, further conditional access controls (such as for special business rules), and assurance&lt;br /&gt;that all the above are operating properly and consistently. The following sections discuss these&lt;br /&gt;security concepts as supported by Oracle8i.&lt;br /&gt;Strong User Authentication For Accountability&lt;br /&gt;The basis for system security is strong user identification and authorization; if you cannot establish,&lt;br /&gt;with certainty, who a user is, then it is impossible to hold users accountable for their actions, and to&lt;br /&gt;ensure that users only have access to the data they need to do their jobs, but no more. Oracle8i supports&lt;br /&gt;a number of choices for user authentication: Oracle-based (by password, or by industry-standard X.509&lt;br /&gt;certificates), host-based (by the underlying operating system), or third-party based (network&lt;br /&gt;authentication services, smart cards and biometric devices).&lt;br /&gt;Oracle Password-Based Authentication&lt;br /&gt;In Oracle password-based authentication, each Oracle8™ user must have a username and password.&lt;br /&gt;To connect to the database, a properly-authenticated operating system user must supply his database&lt;br /&gt;username and password. However, password-based schemes, to be secure, must ensure that passwords&lt;br /&gt;can be changed regularly, are of sufficient complexity, and are not easily guessed.&lt;br /&gt;Oracle8 provides built-in, robust password management facilities to enable administrators to:&lt;br /&gt;· Enforce minimal password length.&lt;br /&gt;· Ensure password complexity (i.e., that passwords contain symbols or numbers as well as&lt;br /&gt;alphabetic characters).&lt;br /&gt;· Disallow passwords that are easily guessed words, such as a user’s last name or&lt;br /&gt;company name.&lt;br /&gt;Administrators can prevent password-guessing attempts by locking accounts automatically after a&lt;br /&gt;number of incorrect password entries; an administrator can also lock an account “on the fly” if he&lt;br /&gt;detects a security breach. Passwords can be forced to expire over any period (every ninety days, for&lt;br /&gt;example) to ensure that users change their passwords regularly. Administrators can also prevent&lt;br /&gt;passwords from being reused, either permanently, or for a specified period of time. Password&lt;br /&gt;preferences may be assigned to an entire enterprise, groups of users, or individual users by&lt;br /&gt;means of user profiles, providing complete flexibility for an organization to implement desired security&lt;br /&gt;preferences.&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;3&lt;br /&gt;In distributed systems, a password passing from a client to server may pose a security risk. If the&lt;br /&gt;password is passed in clear text (unencrypted), any eavesdropper snooping for data can also read the&lt;br /&gt;password. The Oracle password protocol provides security for client-server and server-server password&lt;br /&gt;communication by encrypting passwords passed over a network. The Oracle password protocol uses a&lt;br /&gt;session key valid for a single database connection attempt to encrypt the user's password. Each&lt;br /&gt;connection attempt uses a separate key for encryption, making the encryption more difficult to decipher.&lt;br /&gt;After the key-encrypted password is passed to the server, the server decrypts it, then re-encrypts it using&lt;br /&gt;a Data Encryption Standard (DES) based one-way encryption algorithm and compares it with the&lt;br /&gt;password stored in the database. If they match, the user successfully connects to the database. The&lt;br /&gt;Oracle password protocol is used to encrypt all passwords upon an attempted connection — whether&lt;br /&gt;local connection, client to server, or server to server. Oracle8i also supports secure remote&lt;br /&gt;administration protected by password, even when the database is not available. Users connecting as&lt;br /&gt;SYSDBA and SYSOPER connect using user-specific passwords, providing individual accountability&lt;br /&gt;for these privileged users.&lt;br /&gt;Host-Based Authentication&lt;br /&gt;Oracle8i's identification and authentication facility also allows you to specify that users should be&lt;br /&gt;authenticated by operating system mechanisms, consolidating username and password information and&lt;br /&gt;allowing users to enter an application without having to specify a username and password.&lt;br /&gt;Third Party-Based Authentication&lt;br /&gt;Oracle Advanced Security, an option to Oracle8i, supports multiple third-party authentication&lt;br /&gt;technologies, such as Kerberos, DCE, smart cards and biometric authentication (Identix), as well as&lt;br /&gt;integration with Bull’s ISM and ICL’s Access Manager. These hardware and software technologies&lt;br /&gt;verify a user’s identity in a stronger way than passwords. For example, SecurID cards provide twofactor&lt;br /&gt;authentication — something you have (the card) and something you know (a personal&lt;br /&gt;identification number (PIN)). Many of these network authentication services also provide single signon&lt;br /&gt;for users. Users authenticate themselves once to a central service (e.g., Kerberos), and may then&lt;br /&gt;connect to multiple applications or databases without providing additional credentials. In addition, any&lt;br /&gt;device compliant with RADIUS (Remote Authentication Dial-In User Service) is capable of integrating&lt;br /&gt;with Oracle8i to provide strong user authentication. Oracle8i’s integration with third-party security&lt;br /&gt;providers offers customers a choice among a number of strong authentication and single sign-on&lt;br /&gt;services.&lt;br /&gt;Public Key Infrastructure-Based Authentication&lt;br /&gt;Oracle8 introduced single sign-on for Oracle users through X.509 (version 1) digital certificates and a&lt;br /&gt;proprietary authentication protocol. The advantage of X.509 certificates is that they may be used to&lt;br /&gt;uniquely identify an individual within an organization and thus enable strong authentication. Also,&lt;br /&gt;instead of remembering multiple passwords, a user need only remember the password that unlocks his&lt;br /&gt;Oracle wallet. The certificate and private key contained in the wallet are used to authenticate the user&lt;br /&gt;to multiple services, including application servers and data servers, which need no longer store and&lt;br /&gt;manage local passwords for users.&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;4&lt;br /&gt;Oracle Advanced Security offers enhanced PKI-based single sign-on through use of interoperable X.509&lt;br /&gt;(version 3) certificates for authentication over Secure Sockets Layer (SSL), the standard for Internet&lt;br /&gt;authentication. In addition to strong user authentication, SSL also provides network data confidentiality&lt;br /&gt;and data integrity for multiple types of connections: LDAP (Lightweight Directory Access Protocol), IIOP&lt;br /&gt;(Internet Intra-ORB Protocol), and Net8™ .&lt;br /&gt;Oracle Wallet Manager provides secure management of PKI (public key infrastructure)-based user&lt;br /&gt;credentials: a user’s private key, his certificate, and a list of trustpoints, the list of root certificates that&lt;br /&gt;the user trusts. Wallets are protected using password-based, strong encryption.&lt;br /&gt;In most cases, a user need never access a wallet once it has been configured, but can easily access his&lt;br /&gt;wallet using Oracle Enterprise Login Assistant, a very simple-to-use login tool that hides the complexity&lt;br /&gt;of a private key and certificate from users. Once users have securely opened their wallets, they can then&lt;br /&gt;connect to multiple databases over SSL, without providing additional passwords. This provides the&lt;br /&gt;benefit of strong authentication as well as single sign-on.&lt;br /&gt;Remote Authentication&lt;br /&gt;Oracle Advanced Security supports remote authentication of users through RADIUS, a standard&lt;br /&gt;lightweight protocol used for user authentication, authorization, and accounting. RADIUS, a proposed&lt;br /&gt;standard of the Internet Engineering Task Force (IETF), is a popular means of enabling remote&lt;br /&gt;authentication of users. For example, a user accessing his corporate network remotely first authenticates&lt;br /&gt;himself to RADIUS; then, after successful authentication, the user is able to access applications within his&lt;br /&gt;corporate network.&lt;br /&gt;Oracle Advanced Security provides an interface which can be used with any third-party authentication&lt;br /&gt;service that supports the RADIUS protocol. The advantage to customers is that multiple authentication&lt;br /&gt;devices (for example, tokens or smart cards) may be used for authentication to the Oracle8i database, as&lt;br /&gt;long as the mechanism or device supports the RADIUS protocol.&lt;br /&gt;Authentication Through a Middle Tier&lt;br /&gt;In applications which use a heavy middle tier, such as a transaction processing monitor, it is important&lt;br /&gt;to be able to preserve the identity of the client connecting to the middle tier. Yet, one advantage of a&lt;br /&gt;middle tier is connection pooling, to allow multiple users to access a data server without each of them&lt;br /&gt;needing a separate connection. In such environments, you need to be able to set up (and break down)&lt;br /&gt;connections very quickly, without the overhead of establishing a separate, authenticated database&lt;br /&gt;session for each connection. For these environments, Oracle8i offers n-tier authentication, “lightweight&lt;br /&gt;session” creation via the Oracle® Call Interface, so that applications can have multiple user sessions&lt;br /&gt;within a single database session. These “lightweight sessions” allow each user to be authenticated by a&lt;br /&gt;database password, without the overhead of a separate database connection, as well as preserving the&lt;br /&gt;identity of the real user through the middle tier. See “Authentication through a Middle Tier,” described&lt;br /&gt;later in this paper.&lt;br /&gt;Mutual Authentication For Secure Distributed Computing&lt;br /&gt;While user authentication is important, it is equally important in distributed systems to ensure&lt;br /&gt;that a number of network principals ¾ including application servers, web servers, and database servers&lt;br /&gt;¾ are who they say they are. For example, database A, attempting to connect to database B, needs&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;5&lt;br /&gt;assurance that database B really is database B, just as database B needs to be sure of database A’s&lt;br /&gt;identity.&lt;br /&gt;Oracle8i enables secure distributed transactions ¾ without compromising user credentials ¾ by means&lt;br /&gt;of mutual authentication of databases, and by strong user authentication without disclosure of&lt;br /&gt;credentials. Mutual database authentication and strong user authentication are accomplished by&lt;br /&gt;industry-standard X.509 (version 3) certificates, without using passwords or any other “hard-coded,”&lt;br /&gt;potentially vulnerable means of authentication. Furthermore, administrators can configure their systems&lt;br /&gt;so that databases are only trusted to connect as certain users. For example, an AP application might&lt;br /&gt;need to retrieve information about employees from the HR database in order to perform expense&lt;br /&gt;reporting processing. Not only could the AP and HR databases mutually authenticate, but the HR&lt;br /&gt;database could grant access to only those users in AP who need to query the employee information in&lt;br /&gt;order to process expense reports.&lt;br /&gt;Privileges That Protect Data&lt;br /&gt;To insure data security, Oracle8i implements "security by default." A user can only perform an&lt;br /&gt;operation on a database object (such as a table or view) if that user has been authorized to perform&lt;br /&gt;that operation. A privilege is an authorization to perform a particular operation; without privileges, a&lt;br /&gt;user cannot access any information in the database. To ensure data security, a user should only be&lt;br /&gt;granted those privileges that he needs to perform his job functions. This is known as the principle of&lt;br /&gt;“least privilege.”&lt;br /&gt;To allow you to grant users only those specific privileges they need to perform their jobs, and not any&lt;br /&gt;more, Oracle8i provides a large number of very granular privileges. These privileges fall into two&lt;br /&gt;categories: system privileges and object privileges.&lt;br /&gt;System Privileges&lt;br /&gt;A system privilege authorizes a user to perform a specific operation. One example of a system privilege&lt;br /&gt;is the CREATE USER privilege, which allows a user to create a database username; another is&lt;br /&gt;SELECT ANY TABLE, which allows a user to query any table in the database. Oracle8i provides over&lt;br /&gt;100 different system privileges, such as permission to connect to the database and permission to change&lt;br /&gt;a table's attributes. A privilege can be granted to a user “with ADMIN option.” This allows the&lt;br /&gt;grantee authority to further grant and revoke privileges from other users.&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;6&lt;br /&gt;Object Privileges&lt;br /&gt;An object privilege authorizes a user to perform a specific operation on a specific object. For example,&lt;br /&gt;you can grant a user the ability to select from the EMP table by granting him the SELECT privilege on&lt;br /&gt;that table. With this privilege, the user can query the EMP table but cannot query any other tables in&lt;br /&gt;the database nor update the EMP table. You can also grant object privileges “with GRANT option.”&lt;br /&gt;This allows the grantee authority to further grant the object privilege to other users. Oracle8i provides a&lt;br /&gt;varying number of object privileges per object type, such as permission to insert into a table and&lt;br /&gt;permission to select from a sequence.&lt;br /&gt;By providing these two types of very granular privileges, Oracle8i allows you to implement separation&lt;br /&gt;of function and to control access to information at a very fine level, ensuring that database users are&lt;br /&gt;only authorized to perform those specific operations required by their job functions. In addition, other&lt;br /&gt;Oracle8i features (like roles and stored procedures, described later in this paper) not only allow you to&lt;br /&gt;control which privileges a user has, but under what conditions he can use those privileges.&lt;br /&gt;Secure Metadata&lt;br /&gt;Oracle8i also provides protection for the data dictionary, ensuring that only those individuals making a&lt;br /&gt;database administrator-privileged connection can alter the data dictionary. In Oracle8i, users granted&lt;br /&gt;ANY privilege (such as ALTER ANY TABLE, DROP ANY VIEW) can exercise these privileges on&lt;br /&gt;any appropriate object in any schema, except the SYS schema, which includes the data dictionary. This&lt;br /&gt;allows developers and others who need privileges on objects in multiple schemas (e.g., ALTER ANY&lt;br /&gt;TABLE) to continue to have that access via ANY privileges, while ensuring that they do not&lt;br /&gt;inadvertently alter the data dictionary. Users making SYS-privileged connections (that is, connecting as&lt;br /&gt;SYSDBA or SYSOPER) are able to modify the data dictionary, as one would expect a DBA to be able&lt;br /&gt;to do.&lt;br /&gt;Views To Customize Access To Information&lt;br /&gt;While privileges allow you to control which operations a user can perform on database objects, views&lt;br /&gt;allow you to further limit the data that a user can access within these objects. A view is a content- or&lt;br /&gt;context-dependent subset of one or more tables (or views). For example, you can define a view that&lt;br /&gt;allows a manager to view only the information in the EMP table that is relevant to employees in his own&lt;br /&gt;department. The view may contain only certain columns from the base table (or tables), such as the&lt;br /&gt;example below, in which only the employee name and salary information are contained in a view.&lt;br /&gt;Content may also be limited to a subset of the rows in the base table, such as a view of the employee&lt;br /&gt;table which contains records for employees assigned to department 20.&lt;br /&gt;Similarly, you can define a view that allows payroll clerks to update payroll information on certain days&lt;br /&gt;of the month only. This flexibility allows you to restrict the data that a user can see or modify to only&lt;br /&gt;that data that he truly needs to access, at only the times that access is appropriate. This allows you to&lt;br /&gt;enforce your unique business rules within the database. View can be created with additional business&lt;br /&gt;considerations in mind. For example, views may be created “with check option,” which enforces that&lt;br /&gt;inserts and updates performed through the view must be accessible by the view query itself. This helps&lt;br /&gt;ensure data consistency from the user’s viewpoint.&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;7&lt;br /&gt;CREATE VIEW&lt;br /&gt;emp_salaries AS&lt;br /&gt;SELECT ename,&lt;br /&gt;salary FROM emp&lt;br /&gt;WHERE mgrname =&lt;br /&gt;user;&lt;br /&gt;SELECT, UPDATE privileges&lt;br /&gt;EMP Table&lt;br /&gt;Not Necessary&lt;br /&gt;Figure 1: A View Controlling Salary Access By Manager&lt;br /&gt;Stored Procedures To Customize Operations On Data&lt;br /&gt;Oracle8i stored procedures offer another powerful and flexible way for you not only to limit those&lt;br /&gt;privileges a user has and the data that he can access, but to define a limited set of related operations that&lt;br /&gt;he can perform within the database. It is often desirable to encapsulate business rules into stored&lt;br /&gt;procedures for several reasons. One of them is that, if security is written in the front-end application,&lt;br /&gt;the user can bypass all the security of the application if the user has direct privileges in the database.&lt;br /&gt;Another reason is that stored procedures help enforce least privilege as well as business integrity, by&lt;br /&gt;ensuring that users have the minimum privileges they need to perform their job functions, and only&lt;br /&gt;access data according to well-formed business rules.&lt;br /&gt;A package is a group of one or more stored procedures that are stored and managed together.&lt;br /&gt;Stored procedures and functions are sets of PL/SQL™ (Oracle's procedural language) or Java™&lt;br /&gt;statements stored in compiled form within the database. You can define a procedure so that it performs&lt;br /&gt;a specific business function, then grant a user the ability to execute that procedure without granting him&lt;br /&gt;any access to the objects and operations that the stored procedure uses. This prevents users from&lt;br /&gt;exercising privileges to perform operations outside of the context of the pre-defined authorized&lt;br /&gt;procedure.&lt;br /&gt;For example, the INCREASE_PAY stored procedure illustrated in Figure 2 allows managers to&lt;br /&gt;increase their employees' salaries. By executing this stored procedure, managers are allowed to&lt;br /&gt;increase employees' salaries by no more than 15 percent.&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;8&lt;br /&gt;While you could have just granted these managers the ability to update the EMP_SALARIES view, the&lt;br /&gt;stored procedure allows you to enforce your business rules within the database by restricting managers&lt;br /&gt;from giving their employees increases that violate these rules. Note that the managers need not have&lt;br /&gt;access to the EMP_SALARIES view in order to execute this procedure; because a stored procedure&lt;br /&gt;performs an explicitly defined operation, users only need permission to execute this procedure, not&lt;br /&gt;permission to access the underlying objects. This prevents users from accessing the procedure's&lt;br /&gt;underlying objects outside the context of your business rules.&lt;br /&gt;UPDATE privilege&lt;br /&gt;Not Necessary&lt;br /&gt;EXECUTE privilege&lt;br /&gt;Create procedure INCREASE_PAY&lt;br /&gt;(employee_no in number, increase_amount&lt;br /&gt;In number)&lt;br /&gt;as begin&lt;br /&gt;if increase_amount &lt;= .15&lt;br /&gt;then&lt;br /&gt;update emp_salaries&lt;br /&gt;set salary = salary*(1+increase_amount)&lt;br /&gt;where empno= employee_no;&lt;br /&gt;else&lt;br /&gt;null;&lt;br /&gt;end if;&lt;br /&gt;end;&lt;br /&gt;EMP_SALARIES view&lt;br /&gt;Figure 2. Stored Procedure To Update Salary&lt;br /&gt;Flexible Procedures To Lower Cost of Ownership&lt;br /&gt;The type of procedure described above relies on a “definer’s rights” privilege model; for example, users&lt;br /&gt;who have EXECUTE permission on Chuck’s (the definer’s) procedure access Chuck’s data with&lt;br /&gt;Chuck’s privilege set, for the duration of the transaction only. “Definer’s rights” procedures are useful&lt;br /&gt;for encapsulation of privileges within a business context; that is, users need not have direct privilege on&lt;br /&gt;objects, merely the privilege to execute a procedure which accesses objects according to well-defined&lt;br /&gt;business rules.&lt;br /&gt;However, object-oriented technology and the use of new programming languages such as Java require a&lt;br /&gt;more flexible privilege model, in which business logic is separate from data and the privileges required&lt;br /&gt;to access an object. For example, an Enterprise JavaBeans™ that updates a bank account balance&lt;br /&gt;should update Jane’s account balance if Jane accesses the bean, but John’s account balance if John&lt;br /&gt;accesses the bean. Furthermore, the Enterprise JavaBeans may be deployed in a bean store, and the&lt;br /&gt;beans may actually act upon different databases, or different schemas within the same database.&lt;br /&gt;Alternatively, developers of data cartridges wish to deploy application libraries, in which business logic&lt;br /&gt;must remain independent of specific users’ privileges. To support these requirements, Oracle8i extends&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;9&lt;br /&gt;its privilege model by offering “invoker’s rights” procedures, available in both PL/SQL and Java, which&lt;br /&gt;execute with an invoker’s privilege set, on an invoker’s schema.&lt;br /&gt;Invoker’s rights procedures enable organizations to lower their cost of deploying applications, since&lt;br /&gt;business logic — for example, a procedure which updates account balances — is not tied to a particular&lt;br /&gt;user’s privilege set or a particular schema, and thus can be used (and reused) by many applications and&lt;br /&gt;users. For example, an organization may have a common set of applications which multiple divisions&lt;br /&gt;use, but the data upon which the applications act are separated from one another. Division 1 employees&lt;br /&gt;never access Division 2’s data, and vice versa. One approach to this problem would be to physically&lt;br /&gt;separate data on different servers, which is expensive, and makes it difficult to do necessary summaries&lt;br /&gt;at a corporate level. Another approach is to maintain the data of each application in a separate schema,&lt;br /&gt;and have the application reside in an application-owned schema. Invoker’s rights procedures enable&lt;br /&gt;users from each division to access the same application, while acting upon their own data only.&lt;br /&gt;Invoker’s rights procedures thus enhance the ability of organizations to deploy common applications&lt;br /&gt;which nonetheless “act” differently for different sets of users. The result is stronger security at a lower&lt;br /&gt;cost of deployment.&lt;br /&gt;The Virtual Private Database&lt;br /&gt;Giving customers and partners direct access to mission-critical systems over the Internet may yield&lt;br /&gt;reduced cost, better service, and more timely information, but it also offers new challenges.&lt;br /&gt;Organizations must not only keep data safe from prying eyes, but they must segregate data&lt;br /&gt;appropriately, often to the level of individual customers or users. Also, many companies are interested&lt;br /&gt;in providing Internet “hosting” environments, with a well-designed and well-managed computing&lt;br /&gt;infrastructure, but must keep the data of each “hosted” corporation separate and secure from each other,&lt;br /&gt;while allowing customizations and data access methods which best meet their individual needs.&lt;br /&gt;Within the Intranet, organizations continue to struggle with traditional access control problems, such as&lt;br /&gt;the classic “application security problem”: when access control is embedded in an application, users&lt;br /&gt;who have access to ad-hoc queries or reporting tools bypass the security mechanisms of the application.&lt;br /&gt;Oracle8i addresses these diverse security needs by introducing the Virtual Private Database ¾ serverenforced,&lt;br /&gt;flexible, fine-grained access control, together with a secure application context, enabling&lt;br /&gt;multiple customers and partners to have secure direct access to mission-critical data. The Virtual Private&lt;br /&gt;Database enables, within a single database, per-user or per-customer data access with the assurance of&lt;br /&gt;physical data separation. For Internet access, the Virtual Private Database can ensure that online&lt;br /&gt;banking customers see only their own accounts, and that web storefront customers see their own orders&lt;br /&gt;only. Web hosting companies can maintain multiple companies’ data in the same Oracle8i database,&lt;br /&gt;while allowing each company to see only their own data.&lt;br /&gt;The Virtual Private Database enables fine-grained access control by associating one or more security&lt;br /&gt;policies with tables or views. Direct or indirect access to a table with an attached security policy causes&lt;br /&gt;the data server to consult the policy function. The policy function returns an access condition known as&lt;br /&gt;a predicate (a WHERE clause) which the data server appends to the SQL statements, dynamically&lt;br /&gt;modifying the user’s data access. For example, if an organization’s security policy is that customers&lt;br /&gt;can see their own orders, a user issuing the following query:&lt;br /&gt;SELECT * FROM orders;&lt;br /&gt;could have her query transparently and dynamically rewritten by Oracle8i as follows:&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;10&lt;br /&gt;SELECT * FROM orders WHERE cust_num = SYS_CONTEXT (‘userenv’,&lt;br /&gt;‘session_user’);&lt;br /&gt;This limits access to only those orders for which the customer matches the logged-in user.&lt;br /&gt;The Virtual Private Database enables dynamically modified data access, transparently to both users and&lt;br /&gt;applications, based on any criteria; an organization can have different access conditions per user, per&lt;br /&gt;group of users, or per application.&lt;br /&gt;Flexible Implementation&lt;br /&gt;The Virtual Private Database offers flexible policy implementation, to allow customers to fine-tune their&lt;br /&gt;security policies based on their specific needs:&lt;br /&gt;· Attach security policies to tables or views. Many applications already use views for security&lt;br /&gt;reasons, or to enforce business rules. Attaching security policies to either views or tables allows&lt;br /&gt;organizations to add fine-grained access to their existing applications without completely&lt;br /&gt;rewriting them.&lt;br /&gt;· Add security policies to only those tables or views where it is needed. For example, to&lt;br /&gt;implement the policy ‘customers can see only their own orders,’ one need only add security&lt;br /&gt;policies to the ORDERS and ORDER_LINES table.&lt;br /&gt;· Enable different policies for different types of access, (e.g., select, insert, delete, and update).&lt;br /&gt;For example, you could implement a policy on the EMP table that enables users to query name&lt;br /&gt;and address information for any employee, but allows them to update only their own records.&lt;br /&gt;· Add multiple policies per table. For example, a hosting application may allow different&lt;br /&gt;companies’ HR systems to enable different access control conditions. Companies can add&lt;br /&gt;additional security policies on top of the base HR application security policy (e.g., that data access&lt;br /&gt;is limited by company), without affecting the base security enforcement and data separation&lt;br /&gt;policies.&lt;br /&gt;Context-Based Security Enforcement&lt;br /&gt;To make the Virtual Private Database easy to implement, Oracle8i offers application contexts:&lt;br /&gt;secure, application-specific attributes on which you can base your fine-grained access control policies.&lt;br /&gt;Application contexts are completely user-definable, as are their attributes. A human resources&lt;br /&gt;application may base its security policy on ‘organization,’‘employee number,’ and ‘position.’ For&lt;br /&gt;example, a user in the ‘manager’ position can see the employee records of all employees in his&lt;br /&gt;‘organization,’ while a user in the ‘employee’ position can only see and update records matching his&lt;br /&gt;own ‘employee number.’ Alternatively, a general ledger application may base its security policy on ‘set&lt;br /&gt;of books,’ and ‘cost center.’ You can use application contexts within policy functions to determine the&lt;br /&gt;correct access condition (predicate) to return. You can also use application contexts within a predicate.&lt;br /&gt;Oracle8i ensures that application contexts are secure, by enforcing that only trusted packages implement&lt;br /&gt;them and can set context values.&lt;br /&gt;Oracle8i also provides access to session primitives ¾ information the database maintains about a user&lt;br /&gt;session ¾ which can be used for access control. The USERENV application context provides access to&lt;br /&gt;these session primitives, including external name, proxy user and userid, protocol, port number, and full&lt;br /&gt;DN (distinguished name) from an X.509 certificate.&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;11&lt;br /&gt;Predefined attributes can be very useful for access control. For example, if you are using a three-tier&lt;br /&gt;application which creates lightweight user sessions through OCI, you can access the PROXY_USER&lt;br /&gt;attribute in the USERENV application context to determine whether the user's session was created by a&lt;br /&gt;middle tier application. Your policy function could allow a user to access data only for connections&lt;br /&gt;where the user is proxied. If not (that is, in cases where the user is connecting directly to the database),&lt;br /&gt;the user would not be able to access any data. You could use the information in the DN to perform&lt;br /&gt;access control; for example, you could use the OU (Organizational Unit) component of a DN to limit&lt;br /&gt;users to viewing their own organization’s records only.&lt;br /&gt;Scaleable Security&lt;br /&gt;Fine-grained access control is highly scaleable; rewritten statements are fully parsed, optimized and&lt;br /&gt;available to be shared by other users. Use of application context with fine-grained access control offers&lt;br /&gt;even greater performance benefits, because an application context functions as a secure data cache. For&lt;br /&gt;example, if you were to rewrite a query to limit data access based on a user’s position, organizational&lt;br /&gt;unit, and employee number, you could either use a subquery to retrieve all these values from metadata&lt;br /&gt;tables (which may involve several full table scans), or you could retrieve these&lt;br /&gt;values into an application context and reference the context within your security policy whenever&lt;br /&gt;you need to access attributes. As a result, you can have highly granular access control, with&lt;br /&gt;excellent performance.&lt;br /&gt;Strong, Server-Enforced Security&lt;br /&gt;The Virtual Private Database provides the following benefits:&lt;br /&gt;· Lower Cost of Ownership. Organizations can reap huge cost savings by building security once, in&lt;br /&gt;the data server, instead of implementing the same security in each application that accesses data.&lt;br /&gt;· Eliminate the “Application Security Problem.” Users can no longer bypass security policies&lt;br /&gt;embedded in applications because security policies are associated directly with data. The same&lt;br /&gt;security policy is automatically enforced by the data server, no matter how a user accesses data,&lt;br /&gt;whether through a report-writing tool, a query, or through an application.&lt;br /&gt;· Enable Applications You Could Never Build Before. In the past, organizations could not give&lt;br /&gt;customers and partners direct access to their production systems, because there was no way to&lt;br /&gt;secure the data. Internet hosting companies could not have data for multiple companies reside in&lt;br /&gt;the same data server, because they could not separate each company’s data. Now, all these&lt;br /&gt;scenarios are possible, because the Virtual Private Database gives you server-enforced, finegrained&lt;br /&gt;access control with the assurance of physical data separation.&lt;br /&gt;Triggers To Customize Functionality&lt;br /&gt;Like stored procedures, database triggers are user-defined sets of PL/SQL or Java statements, also&lt;br /&gt;stored in compiled form. While users explicitly execute stored procedures, database triggers are&lt;br /&gt;automatically executed (or "fired") within the data server based on pre-specified events. A trigger is&lt;br /&gt;defined to execute either before or after an insert, update, or delete, so that when that operation is&lt;br /&gt;performed on that table, the trigger automatically fires. Four types of triggers are available for&lt;br /&gt;definition on a table: BEFORE statement, BEFORE row, AFTER statement, and AFTER row.&lt;br /&gt;Statement triggers are executed once regardless of the number of rows affected by the triggering&lt;br /&gt;statement. Row triggers are fired once for each row affected by the triggering statement.&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;12&lt;br /&gt;The security benefits of database triggers are similar to those of stored procedures: more granular&lt;br /&gt;access control and consistent rule enforcement. In addition to those benefits, database triggers allow&lt;br /&gt;you to perform behind-the-scenes operations based on user activity. For example, you could define a&lt;br /&gt;BEFORE UPDATE trigger on the EMP table that automatically records the existing values in the table&lt;br /&gt;before a user updates them. That way, you have a record of both the old and new values in any updated&lt;br /&gt;rows. You can also define multiple triggers of each type (statement or row) on a single table, to audit&lt;br /&gt;several different types of operations. Triggers can be used to apply security rules to the database. For&lt;br /&gt;example, if employee salary information should only be updated on a weekday between 8 a.m. and 6&lt;br /&gt;p.m., a trigger can be defined to implement this business rule:&lt;br /&gt;CREATE TRIGGER check_salary_access&lt;br /&gt;before delete or insert or update&lt;br /&gt;ON scott.emp&lt;br /&gt;BEGIN&lt;br /&gt;/* If today is a Saturday or Sunday, then return an error.*/&lt;br /&gt;IF(TO_CHAR(SYSDATE, 'DY') = 'SAT' OR&lt;br /&gt;TO_CHAR(SYSDATE, 'DY') = 'SUN')&lt;br /&gt;THEN raise_application_error( -20501,&lt;br /&gt;'May not change employee table during the weekend');&lt;br /&gt;ENDIF;&lt;br /&gt;/*If the current time is before 8:00AM or after 6:00PM, then&lt;br /&gt;return an error. */&lt;br /&gt;IF (TO_CHAR(SYSDATE, 'HH24') &lt; 8 OR&lt;br /&gt;TO_CHAR(SYSDATE, 'HH24') &gt;=18)&lt;br /&gt;THEN raise_application-error(-20502,'May only change&lt;br /&gt;employee&lt;br /&gt;table during working hours');&lt;br /&gt;ENDIF;&lt;br /&gt;END;&lt;br /&gt;All actions and checks done as a result of the SQL statement in a trigger must succeed. If any step is&lt;br /&gt;not successful, then all transactions are rolled back, ensuring data integrity.&lt;br /&gt;While database triggers allow you to extend security based on actions involving specific database&lt;br /&gt;tables, event triggers allow you to extend security (e.g., access control and auditing) on larger events&lt;br /&gt;occurring within the database. Oracle8i provides event triggers on multiple database events, including&lt;br /&gt;login, logoff, startup, shutdown, as well as create, alter, and drop. Event triggers may be defined at the&lt;br /&gt;database level (e.g., startup), or for individual schemas (e.g., CREATE statements in the Order Entry&lt;br /&gt;schema).&lt;br /&gt;For example, you could enable security policies immediately on login, based on how a user logged in or&lt;br /&gt;where he connected from. Or, you could use a login trigger to immediately set an application context&lt;br /&gt;for a user, to limit his access to data. You could use a login trigger to automatically enable more&lt;br /&gt;stringent auditing if a user connects to the database outside normal working hours, and disable these&lt;br /&gt;auditing options with a logoff trigger. Event triggers can be used to extend the innate security&lt;br /&gt;mechanisms of the Oracle8i data server, giving organizations more control over how and when users&lt;br /&gt;access data.&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;13&lt;br /&gt;Roles To Manage Privileges&lt;br /&gt;While Oracle8i's granular privileges let you closely restrict the types of operations a user can perform in&lt;br /&gt;the database, managing these privileges may be complex. For example, if ten payroll clerks are&lt;br /&gt;responsible for maintaining payroll information, you would be required to grant each of these ten users&lt;br /&gt;the privileges necessary for him to perform his job. If their managers also must have access to&lt;br /&gt;information, you must grant these privileges to the managers, as well. If you decide to reduce the&lt;br /&gt;number of privileges these users require, you must revoke privileges from each of these users&lt;br /&gt;individually, making privilege management time-consuming and complex.&lt;br /&gt;To address the complexity of privilege management, Oracle7™ introduced roles. Roles are user-defined&lt;br /&gt;collections of privileges that can be granted to and revoked from users, and even from other roles. For&lt;br /&gt;example, you can create the PAYROLL_CLERK role, grant it all privileges necessary for payroll&lt;br /&gt;clerks to perform their jobs, then simply grant this single role to all payroll clerks. In addition, you can&lt;br /&gt;create the PAYROLL_MANAGER role, grant it the PAYROLL_CLERK role and any other necessary&lt;br /&gt;privileges, then grant it to all payroll managers. To later grant an additional privilege to all payroll&lt;br /&gt;clerks and their managers, you need only grant an additional privilege to the PAYROLL_CLERK role;&lt;br /&gt;similarly, to revoke a privilege from all payroll clerks and managers, you need only revoke the privilege&lt;br /&gt;from the role. A role can also be defined to prompt the user for a password when that role is invoked,&lt;br /&gt;thus providing another layer of security for the system.&lt;br /&gt;In addition to using roles to simplify privilege management, you can use roles to restrict the set of&lt;br /&gt;privileges accessible to a user at any time. For example, you can specify "default" roles that are&lt;br /&gt;enabled automatically for a user whenever he connects to the database, and specify additional roles that&lt;br /&gt;can only be enabled explicitly (by the user or within an application). You can also explicitly disable a&lt;br /&gt;role for a user to prevent him from using a certain collection of privileges when it is no longer&lt;br /&gt;appropriate (such as when he changes jobs). In addition, a role can be dropped completely from the&lt;br /&gt;database, making it no longer available to any user.&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;14&lt;br /&gt;Clerk&lt;br /&gt;Manager&lt;br /&gt;Users Roles&lt;br /&gt;Human&lt;br /&gt;Resources&lt;br /&gt;Clerk&lt;br /&gt;Human&lt;br /&gt;Resources&lt;br /&gt;Manager&lt;br /&gt;Default&lt;br /&gt;Default&lt;br /&gt;EMP Table&lt;br /&gt;BONUS Table&lt;br /&gt;Privileges&lt;br /&gt;CREATE SESSION&lt;br /&gt;SELECT&lt;br /&gt;SELECT&lt;br /&gt;UPDATE&lt;br /&gt;UPDATE&lt;br /&gt;INSERT&lt;br /&gt;DELETE&lt;br /&gt;Figure 3: Use Roles To Assign Users Groups of Privileges&lt;br /&gt;Roles To Manage Application Security&lt;br /&gt;One beneficial use of the ability to dynamically enable and disable roles is to associate a role with an&lt;br /&gt;application. You can specify that a certain role be enabled for authorized users at the beginning of the&lt;br /&gt;application, then disabled at the end of the application. This restricts users from exercising the&lt;br /&gt;privileges within the role outside of the application. For example, you can enable the&lt;br /&gt;PAYROLL_CLERK role at the beginning of the payroll application, then automatically disable it when&lt;br /&gt;a payroll clerk exits from the application. This ensures that payroll clerks do not use the privileges of&lt;br /&gt;the role in any way other than that allowed by business rules defined within the&lt;br /&gt;payroll application.&lt;br /&gt;Roles can also be useful in managing privileges in an application development environment. For&lt;br /&gt;example, certain privileges can be granted to developers to enable them to create their own objects.&lt;br /&gt;These privileges are not required by users of an application but are needed by developers. You can also&lt;br /&gt;associate a role with a database tool, allowing you to control which operations a user can perform using&lt;br /&gt;that tool. For example, you can associate the database roles PAYROLL_CLERK and&lt;br /&gt;PAYROLL_MANAGER with the menu roles in Oracle® Developer so that the tool only displays those&lt;br /&gt;menu entries that are accessible to clerks or managers, based on the enabled roles.&lt;br /&gt;Enterprise Roles For Centralized Privilege Management&lt;br /&gt;The challenge of managing user accounts and privileges is magnified in large enterprises, which often&lt;br /&gt;have a number of employees dedicated to creating user accounts, assigning privileges to them, and&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;15&lt;br /&gt;reassigning privileges as necessary. To address this need, Oracle8 introduced enterprise roles: a&lt;br /&gt;container of one or more global roles (encompassing one or more data servers), centrally administered,&lt;br /&gt;maintained in a proprietary data schema. Through Oracle Advanced Security, Oracle8i extends the&lt;br /&gt;benefits of enterprise roles by storing and retrieving them from Oracle Internet Directory (or selected&lt;br /&gt;other LDAP v3-compliant directory servers) via LDAP, an Internet standard for directory access.&lt;br /&gt;Enterprise roles enable centralized authorization of users; for example, a user may be granted the&lt;br /&gt;enterprise role “HR Clerk,” which contains the global role “HR User” on the Human Resources&lt;br /&gt;database, and the “Employee” global role on the Corporate Information database. If a user changes&lt;br /&gt;jobs, an administrator can simply change his enterprise role assignment, which alters his privileges in&lt;br /&gt;multiple databases throughout the enterprise. Also, you can add capabilities to enterprise roles (granted&lt;br /&gt;to multiple users) without having to update the authorizations of each user independently.&lt;br /&gt;User/Schema Separation&lt;br /&gt;A benefit of managing users in a directory is that it may reduce the number of user accounts needed. In&lt;br /&gt;most cases, users do not need their own accounts - or their own schemas - in a database. Typically,&lt;br /&gt;users merely need to access an application schema. For example, suppose users John, Firuzeh and Jane&lt;br /&gt;are all users of the Payroll application, and they need access to the Payroll schema on the Finance&lt;br /&gt;database. None of them needs to create their own objects in the database; in fact, they need only access&lt;br /&gt;Payroll objects. For most applications, users should be able to share a schema since they don’t need to&lt;br /&gt;create their own objects in the database.&lt;br /&gt;Oracle Advanced Security supports mapping many enterprise users to the same shared schema on an&lt;br /&gt;individual database. This separation of users from schemas reduces the cost of user administration.&lt;br /&gt;Instead of creating a user account (that is, a user schema) in each database a user needs to access, as&lt;br /&gt;well as creating the user in the directory, you can create a user once, in the directory, and “point” the&lt;br /&gt;user at a shared schema that many other enterprise users can also access. In the previous example, if&lt;br /&gt;John, Firuzeh and Jane all access the Sales database, you need only create a single schema, e.g.&lt;br /&gt;‘SALES_APPLICATION’ which all three users can access, instead of creating an account for each user&lt;br /&gt;on the Sales database.&lt;br /&gt;User/schema separation reaps the benefit of deploying a directory within the enterprise. Centralized user&lt;br /&gt;administration and far fewer user accounts provides thus provides greater security as well as lower cost&lt;br /&gt;of ownership.&lt;br /&gt;Single Station Administration&lt;br /&gt;Managing thousands of user accounts is one of the largest administration challenges facing large&lt;br /&gt;organizations. Creating user accounts and assigning privileges is often a multi-step process, requiring&lt;br /&gt;multiple tools. Significant new functionality has been added in Oracle8i to address this need. Oracle&lt;br /&gt;Enterprise Security Manager (an extension to Oracle’s traditional database security manager) provides&lt;br /&gt;“single station administration.” From a single console, an administrator can perform the following:&lt;br /&gt;· Create a enterprise users in Oracle Internet Directory&lt;br /&gt;· Create a user in multiple Oracle8i databases&lt;br /&gt;· Create a shared schema&lt;br /&gt;· Map enterprise users to shared schemas&lt;br /&gt;· Create enterprise roles that span multiple databases&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;16&lt;br /&gt;· Assign one or more enterprise roles to a user&lt;br /&gt;Oracle Enterprise Security Manager provides one tool to centrally manage enterprise users and their&lt;br /&gt;roles, as well as administer enterprise domains ¾ groups of databases and enterprise roles ¾ resulting&lt;br /&gt;in a lower cost of user administration throughout the enterprise. Another benefit of single station&lt;br /&gt;administration is that if security is easy to administer, organizations are more likely to implement&lt;br /&gt;security well throughout the enterprise.&lt;br /&gt;Auditing To Monitor Database Activity&lt;br /&gt;A critical aspect of any security policy is maintaining a record of system activity to ensure that users are&lt;br /&gt;held accountable for their actions. To address this requirement, Oracle8i provides an extensive audit&lt;br /&gt;facility.&lt;br /&gt;Granular Auditing&lt;br /&gt;The Oracle8i audit facility allows you to audit database activity by statement, by use of system&lt;br /&gt;privilege, by object, or by user. For example, you can audit activity as general as all user connections to&lt;br /&gt;the database, and as specific as a particular user creating a table. You can also audit only successful&lt;br /&gt;operations, or unsuccessful operations. For example, auditing unsuccessful SELECT statements may&lt;br /&gt;catch users on ‘fishing expeditions’ for data they are not privileged to see. You can also set default&lt;br /&gt;object auditing options so that new objects automatically have auditing enabled from object creation (for&lt;br /&gt;example, any new tables are audited automatically for unsuccessful selects). Audit trail records are&lt;br /&gt;stored in an Oracle8i table, making the information available for viewing through ad hoc queries or any&lt;br /&gt;appropriate application or tool.&lt;br /&gt;Efficient Auditing&lt;br /&gt;Oracle8i implements auditing efficiently: statements are parsed once for both execution and&lt;br /&gt;auditing, not separately. Also, auditing is implemented within the server itself, not in a separate,&lt;br /&gt;add-on server which may be remotely situated from the statements which are being executed&lt;br /&gt;(thereby incurring network overhead). The granularity and scope of these audit options allow you&lt;br /&gt;to record and monitor specific database activity without incurring the performance overhead that&lt;br /&gt;more general auditing entails. And, by setting just the options of interest to you, you avoid the&lt;br /&gt;“catch-all, and throw away” audit methods which intercept and log all statements, and then filter&lt;br /&gt;them to retrieve the ones of interest.&lt;br /&gt;Extensible Auditing&lt;br /&gt;To record customized information that is not automatically included in audit records, you can use&lt;br /&gt;triggers (described in "Triggers to Customize Functionality") to further design your own audit auditing&lt;br /&gt;conditions and audit record contents. For example, you could define a trigger on the EMP table to&lt;br /&gt;generate an audit record whenever an employee's salary is increased by more than 10 percent and&lt;br /&gt;include selected information, such as before and after values of SALARY:&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;17&lt;br /&gt;CREATE TRIGGER audit_emp_salaries&lt;br /&gt;AFTER INSERT OR DELETE OR UPDATE ON employee_salaries&lt;br /&gt;for each row&lt;br /&gt;begin&lt;br /&gt;if (:new.salary&gt; :old.salary * 1.10)&lt;br /&gt;then&lt;br /&gt;insert into emp_salary_audit values (&lt;br /&gt;:employee_no,&lt;br /&gt;:old.salary,&lt;br /&gt;:new.salary,&lt;br /&gt;user,&lt;br /&gt;sysdate);&lt;br /&gt;endif;&lt;br /&gt;end;&lt;br /&gt;Furthermore, you can use event triggers to enable auditing options for specific users on login, and&lt;br /&gt;disable them on logoff.&lt;br /&gt;Oracle8i also gives you the option of sending audit records to the database audit trail or your operating&lt;br /&gt;system's audit trail, when the operating system is capable of receiving them. This option, coupled with&lt;br /&gt;the broad selection of audit options and the ability to customize auditing with triggers or stored&lt;br /&gt;procedures, gives you the flexibility of implementing an auditing scheme that suits your specific&lt;br /&gt;business needs.&lt;br /&gt;Auditing For Three-Tier Applications&lt;br /&gt;Many three-tier applications authenticate users to the middle tier, then the TP monitor or application&lt;br /&gt;server connects as super-privileged user, and does all activity on behalf of all users. With Oracle8i, you&lt;br /&gt;are not only able to preserve the identity of the real client over the middle tier and enforce “least&lt;br /&gt;privilege” through a middle tier, but you can audit actions taken on behalf of the user by the middle tier.&lt;br /&gt;Oracle8i’s audit records capture both the logged-in user (e.g., the TP monitor) who initiated the&lt;br /&gt;connection, and the user on whose behalf an action is taken. For example, to capture all SELECTs on&lt;br /&gt;the BONUS table done by a middle tier called ‘appsrv,’ you would enabled the following audit option:&lt;br /&gt;AUDIT SELECT ON bonus BY appsrv ON BEHALF OF ANY;&lt;br /&gt;Audit records capture both the user taking the action and the user on whose behalf the action was taken.&lt;br /&gt;Auditing user activity, whether users are connected through a middle tier or directly to the data server,&lt;br /&gt;enhances user accountability, and thus the overall security of multi-tier systems.&lt;br /&gt;Active Auditing&lt;br /&gt;While an auditing facility can record attempts to breach database security or actual breaches, they do&lt;br /&gt;not alert administrators or security officers that the breach is happening. In fact, it can be hours, days,&lt;br /&gt;or months before analysts detect a security breach by examining the audit trail. Consequently, if one of&lt;br /&gt;the purposes of your auditing policy is to detect potential breaches of security, you need an alarm&lt;br /&gt;facility to alert the appropriate administrator when the database or operating system detects&lt;br /&gt;suspicious behavior.&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;18&lt;br /&gt;When you use database triggers to perform customized auditing, Oracle8i can send an alarm to a&lt;br /&gt;waiting process that a potential breach of security is occurring.&lt;br /&gt;AUTHENTICATION THROUGH A MIDDLE TIER&lt;br /&gt;The growth of three-tier systems (for example, browser to application server to database) has increased&lt;br /&gt;dramatically with the growth of the Internet. Indeed, three-tier applications are often referred to as the&lt;br /&gt;"Internet computing model." Oracle8i n-tier authentication addresses many security difficulties that&lt;br /&gt;arise in three-tier applications. It enables organizations to reap the benefits of Internet computing, while&lt;br /&gt;minimizing the security risks of three-tier systems. This section includes:&lt;br /&gt;· Advantages of n-Tier Authentication&lt;br /&gt;· Security Challenges of Three-tier Computing&lt;br /&gt;· Oracle8i n-Tier Authentication Solutions&lt;br /&gt;Advantages of n-Tier Authentication&lt;br /&gt;Three-tier systems provide many benefits to organizations. Application servers and web servers enable&lt;br /&gt;users to access data stored in legacy applications. Users like using a familiar, easy-to-use browser&lt;br /&gt;interface. Organizations can separate application logic from data storage, partitioning the former in&lt;br /&gt;application servers and the latter in databases. Organizations can also lower their cost of computing by&lt;br /&gt;replacing many "fat clients" with a number of "thin clients" and an application server.&lt;br /&gt;In addition, Oracle n-tier authentication delivers the following security benefits:&lt;br /&gt;· A limited trust model, by controlling the users on whose behalf middle tiers can connect, and the&lt;br /&gt;roles the middle tiers can assume for the user&lt;br /&gt;· Scalability, by supporting lightweight user sessions through OCI, and eliminating the overhead of&lt;br /&gt;reauthenticating clients&lt;br /&gt;· Accountability, by preserving the identity of the real user through to the database, and enabling&lt;br /&gt;auditing of actions taken on behalf of the real user&lt;br /&gt;Security Challenges of Three-tier Computing&lt;br /&gt;While three-tier computing provides many benefits, it raises a number of new security issues:&lt;br /&gt;· Who Is the Real User?&lt;br /&gt;· Does the Middle Tier Have Too Much Privilege?&lt;br /&gt;· How to Audit? Whom to Audit?&lt;br /&gt;· Can the User Be Reauthenticated to the Database?&lt;br /&gt;Who Is the Real User?&lt;br /&gt;Most organizations want to know the identity of the actual user who is accessing the database, for&lt;br /&gt;reasons of access control or auditing. User accountability is diminished if the identity of the users&lt;br /&gt;cannot be traced through all tiers of the application.&lt;br /&gt;Furthermore, if only the application server knows who the user is, then all per-user security enforcement&lt;br /&gt;must be done by the application itself. Application-based security is very expensive. If each application&lt;br /&gt;that accesses the data must enforce security, then security must be reimplemented in each and every&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;19&lt;br /&gt;application. It is often preferable to build security on the data itself, with per-user accountability&lt;br /&gt;enforced within the database.&lt;br /&gt;Does the Middle Tier Have Too Much Privilege?&lt;br /&gt;Some organizations are willing to accept three-tier systems within the enterprise, in which "allprivileged"&lt;br /&gt;middle tiers, such as transaction processing (TP) monitors, can perform all actions for all&lt;br /&gt;users. In this architecture, the middle tier connects to the database as the same user for all application&lt;br /&gt;users. It therefore needs to have all privileges that application users need to do their jobs.&lt;br /&gt;This computing model may be undesirable in the Internet, where the middle tier resides outside, on, or&lt;br /&gt;just inside a firewall. More desirable, in this context, is a limited trust model, in which the identity of&lt;br /&gt;the real client is known to the data server, and the application server (or other middle tier) has a&lt;br /&gt;restricted privilege set. Also useful is the ability to limit the users on whose behalf a middle tier can&lt;br /&gt;connect, and the roles the middle tier can assume for the user. For example, many organizations would&lt;br /&gt;prefer that users have different privileges depending on where they are connecting from. A user&lt;br /&gt;connecting to a web server or application server on the firewall might only be able to use very minimal&lt;br /&gt;privileges to access data, whereas a user connecting to a web server or application server within the&lt;br /&gt;enterprise might be able to exercise all privileges she is otherwise entitled to have.&lt;br /&gt;How to Audit? Whom to Audit?&lt;br /&gt;Accountability through auditing is a basic principle of information security. Most organizations want to&lt;br /&gt;know on whose behalf a transaction was accomplished, not just that a particular application server&lt;br /&gt;performed a transaction. A system must therefore be able to differentiate between a user performing a&lt;br /&gt;transaction, and an application server performing a transaction on behalf of a user.&lt;br /&gt;Auditing in three-tier systems should be tied to the issue of knowing the real user: if you cannot preserve&lt;br /&gt;the user’s identity through the middle tier of a three-tier application, you cannot audit actions on behalf&lt;br /&gt;of the user.&lt;br /&gt;Can the User Be Reauthenticated to the Database?&lt;br /&gt;In client/server systems, authentication tends to be straightforward: the client authenticates to the server.&lt;br /&gt;In three-tier systems authentication is more difficult, because there are several potential authentications.&lt;br /&gt;· Client to Middle Tier Authentication&lt;br /&gt;· Middle Tier to Database Authentication&lt;br /&gt;· Client Reauthentication Through Middle Tier to Database&lt;br /&gt;Client to Middle Tier Authentication Client authentication to the middle tier is clearly required if a&lt;br /&gt;system is to conform with basic security principles. The middle tier is typically the first gateway to&lt;br /&gt;useful information that the user can access. Users must, therefore, authenticate to the middle tier. Note&lt;br /&gt;that such authentication may be mutual; that is, the middle tier authenticates to the client just as the&lt;br /&gt;client authenticates to the middle tier.&lt;br /&gt;Middle Tier to Database Authentication Since the middle tier must typically initiate a connection to&lt;br /&gt;a database to retrieve data (whether on its own behalf or on behalf of the user), this connection clearly&lt;br /&gt;must be authenticated. In fact, Oracle8i does not allow unauthenticated connections. Again, middle tier&lt;br /&gt;to database authentication may also be mutual.&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;20&lt;br /&gt;Client Reauthentication Through Middle Tier to Database Client reauthentication from the middle&lt;br /&gt;tier to the database is problematic in three-tier systems. The username may not be the same on the&lt;br /&gt;middle tier and the database. In this case, users may need to reenter a username and password, which&lt;br /&gt;the middle tier uses to connect on their behalf. Or, more commonly, the middle tier may need to map the&lt;br /&gt;username provided, to a database username. This mapping is often done in an LDAP-compliant&lt;br /&gt;directory service, such as Oracle Internet Directory.&lt;br /&gt;For the client to reauthenticate himself to the database, the middle tier either needs to ask the user for a&lt;br /&gt;password (which it then must be trusted to pass to the database), or the middle tier must retrieve a&lt;br /&gt;password for the user and use that to authenticate the user. Both approaches involve security risks,&lt;br /&gt;because the middle tier is trusted to handle the user’s password properly, and not use it maliciously.&lt;br /&gt;One of the only cases for which reauthentication does not involve trusting the middle tier occurs when a&lt;br /&gt;middle tier downloads an applet to a client, and the client connects directly to the database via the&lt;br /&gt;applet. In this case, the application server is literally just that: it serves the application (applet) to the&lt;br /&gt;user, and has no part in further authentication of the user.&lt;br /&gt;Reauthenticating the client to the back-end database is not always beneficial. First, two sets of&lt;br /&gt;authentication handshakes per user involves considerable network overhead. Second, you must trust the&lt;br /&gt;middle tier to have authenticated the user. (You clearly must trust the middle tier if it retrieves or&lt;br /&gt;otherwise is privy to the user’s password.) It is therefore not unreasonable for the database to simply&lt;br /&gt;accept that the middle tier has performed proper authentication. In other words, the database accepts the&lt;br /&gt;identity of the real client without requiring the real client to authenticate herself.&lt;br /&gt;For some authentication protocols, client reauthentication is just not possible. For example, many&lt;br /&gt;browsers and application servers support the Secure Sockets Layer (SSL) protocol. Both the Oracle8i&lt;br /&gt;database (through Oracle Advanced Security) and Oracle Application Server support the use of SSL for&lt;br /&gt;client authentication. However, SSL is a point-to-point protocol, not an end-to-end protocol. It cannot be&lt;br /&gt;used to reauthenticate a browser client (through the middle tier) to the database.&lt;br /&gt;The reason for this is that a user cannot securely give up his private key to the middle tier in order for&lt;br /&gt;the reauthentication of the client to occur. Once the user’s private key is compromised, the user’s very&lt;br /&gt;identity is compromised. In addition, there is no way to "tunnel" through a middle tier so that the&lt;br /&gt;authentication of the browser client to the database can occur directly.&lt;br /&gt;In short, organizations deploying three-tier systems require flexibility as regards reauthentication of the&lt;br /&gt;client. In some cases, they cannot reauthenticate the client; in other cases, they may choose whether or&lt;br /&gt;not to reauthenticate the client.&lt;br /&gt;Oracle8i n-Tier Authentication Solutions&lt;br /&gt;The following sections explain how Oracle8i addresses each of the challenges listed above.&lt;br /&gt;· Passing Through the Identity of the Real User&lt;br /&gt;· Limiting the Privilege of the Middle Tier&lt;br /&gt;· Reauthenticating the Real User&lt;br /&gt;· Auditing Actions Taken on Behalf of the Real User&lt;br /&gt;Database Security in Oracle8i, An Oracle Technical White Paper&lt;br /&gt;November 1999&lt;br /&gt;21&lt;br /&gt;Passing Through the Identity of the Real User&lt;br /&gt;Many organizations want to know who the real user is through all tiers of an application, without&lt;br /&gt;sacrificing the benefits of a middle tier. Oracle8i provides the ability to preserve client identity through&lt;br /&gt;the Oracle Call Interface (OCI). OCI enables a middle tier to set up, within a single database&lt;br /&gt;connection, a number of "lightweight" user sessions, each of which uniquely identifies a connected user.&lt;br /&gt;These lightweight sessions reduce the network overhead of creating separate network connections from&lt;br /&gt;the middle tier to the database. The application can switch between these sessions as required to process&lt;br /&gt;transactions on behalf of users.&lt;br /&gt;The full authentication sequence from the client to the middle tier to the database occurs as follows:&lt;br /&gt;1. The client authenticates to the middle tier, using whatever form of authentication the middle tier&lt;br /&gt;will accept. For example, the client could authenticate to the middle tier using a&lt;br /&gt;username/password, or an X.509 certificate by means of SSL.&lt;br /&gt;2. The middle tier authenticates itself to Oracle8i, using whatever form of authentication Oracle8i will&lt;br /&gt;accept. This could be a password, or an authentication mechanism supported by Oracle Advanced&lt;br /&gt;Security, such as a Kerberos ticket or an X.509 certificate (SSL).&lt;br /&gt;3. The middle tier then creates one or more sessions for users using the Oracle Call Interface. The&lt;br /&gt;lightweight session information must include username as a minimum. The middle tier may&lt;br /&gt;optionally provide a password for the client, and the roles for the client.&lt;br /&gt;4. Since the database cannot require the middle tier to provide a password for the client, authentication&lt;br /&gt;is performed by OCI. To create the session for the client, the middle-tier server calls the&lt;br /&gt;OCISessionBegin function. Prior to calling OCISessionBegin, the OCIAttrSet&lt;br /&gt;function is called to provide the needed information about the client to the middle tier server. It is&lt;br /&gt;called in turn with the following attributes:&lt;br /&gt;· OCI_ATTR_USERNAME ¾ Sets the database user name of the client. This attribute is&lt;br /&gt;mandatory.&lt;br /&gt;· OCI_ATTR_PASSWORD ¾ If the client has provided a database password to be validated by&lt;br /&gt;the database, then the middle tier server passes it along with the username. If this attribute is not&lt;br /&gt;provided, then it is assumed that the middle tier server has authenticated the client.&lt;br /&gt;· OCI_ATTR_PROXY_CREDENTIALS ¾ This attribute tells the server that the client is&lt;br /&gt;connecting through a middle tier server.&lt;br /&gt;· OCI_ATTR_INITIAL_CLIENT_ROLES ¾ If the middle tier server wants to activate a set of&lt;br /&gt;roles upon connecting as the client, then the list is passed along with this attribute.&lt;br /&gt;5. The database verifies that the middle tier is privileged to create sessions on behalf of the user, using&lt;br /&gt;the roles provided. (See "Limiting the Privilege of the Middle Tier," below).&lt;br /&gt;The OCISessionBegin call will fail if the application server is not allowed to proxy on behalf of&lt;br /&gt;the client by the administrator, or if the application server is not allowed to activate the specified roles.&lt;br /&gt;Limiting the Privilege of the Middle Tier&lt;br /&gt;"Least privilege" is the principle that users should have the fewest privileges necessary to perform their&lt;br /&gt;duties, and no more. As applied to middle tier applications, this means that the middle tier should not&lt;br /&gt;have more privileges than it needs. Oracle8i enables you to limit the middle tier such that it can connect&lt;br /&gt;only on behalf of certain users, using only specific roles.&lt;br /&gt;For example, suppose that user Sarah wants to connect to the database through a middle tier, appsrv&lt;br /&gt;(which is also a database user). Sarah has multiple roles, but it is desirable to restrict the middle tier to&lt;br /&gt;exercise only the clerk role on her behalf. A DBA could effectively grant permission for appsrv to&lt;br /&gt;initiate connections on behalf of Sarah using her clerk role only, using the following syntax:&lt;br /&gt;ALTER USER Sarah GRANT CONNECT THROUGH appsrv WITH ROLE clerk;&lt;br /&gt;By default, the middle tier cannot create connections for any client. The permission must be granted on a&lt;br /&gt;per-user basis.&lt;br /&gt;To allow appsrv to use all of the roles granted to the client Sarah, the following statement would be&lt;br /&gt;used:&lt;br /&gt;ALTER USER sarah GRANT CONNECT THROUGH appsrv WITH ROLE ALL;&lt;br /&gt;Each time a middle tier initiates a lightweight (OCI) session for another database user, the database&lt;br /&gt;verifies that the middle tier is privileged to connect for that user, using the role specified.&lt;br /&gt;Reauthenticating the Real User&lt;br /&gt;As described above, it is not always beneficial to reauthenticate users to the database after they have&lt;br /&gt;been authenticated by the middle tier. However, if you wish to do this for an added measure of security,&lt;br /&gt;you can pass the database the user’s password using the OCI_ATTR_PASSWORD attribute of the&lt;br /&gt;OCIAttrSet call.&lt;br /&gt;Auditing Actions Taken on Behalf of the Real User&lt;br /&gt;The n-tier authentication features of Oracle8i enables you to audit actions a middle tier performs on&lt;br /&gt;behalf of a user. For example, suppose an application server hrappserver creates multiple&lt;br /&gt;lightweight sessions for users Ajit and Jane. A DBA could enable auditing for SELECTs on the bonus&lt;br /&gt;table that hrappserver initiates for Jane as follows:&lt;br /&gt;AUDIT SELECT ON bonuses BY hrappserver ON BEHALF OF Jane;&lt;br /&gt;Alternatively, the DBA could enable auditing on behalf of multiple users (in this case, both Jane and&lt;br /&gt;Ajit) connecting through a middle tier as follows:&lt;br /&gt;AUDIT SELECT ON bonuses BY hrappserver ON BEHALF OF ANY;&lt;br /&gt;This auditing option only audits SELECT statements being initiated by hrappserver on behalf of&lt;br /&gt;other users. A DBA can enable separate auditing options to capture SELECTs against the bonus table&lt;br /&gt;from clients connecting directly to the database:&lt;br /&gt;AUDIT SELECT ON bonuses;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;linda ahmed anwar&lt;br /&gt;sec 11&lt;br /&gt;cs&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34158316-115817940309752582?l=lindaahmed.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lindaahmed.blogspot.com/feeds/115817940309752582/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=34158316&amp;postID=115817940309752582' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34158316/posts/default/115817940309752582'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34158316/posts/default/115817940309752582'/><link rel='alternate' type='text/html' href='http://lindaahmed.blogspot.com/2006/09/httpdata-base-secuirty-database.html' title=''/><author><name>linda</name><uri>http://www.blogger.com/profile/12538669834728464262</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='00880586125148893510'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34158316.post-115817624312980068</id><published>2006-09-13T11:55:00.000-07:00</published><updated>2006-09-13T12:41:27.283-07:00</updated><title type='text'></title><content type='html'>&lt;a href="http://photos1.blogger.com/blogger/3782/3760/1600/untitled.jpg"&gt;&lt;/a&gt;&lt;a href="http://photos1.blogger.com/blogger/3782/3760/1600/XPPRO.jpg"&gt;&lt;img style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" height="241" alt="" src="http://photos1.blogger.com/blogger/3782/3760/320/XPPRO.jpg" width="357" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://learning"&gt;http://learning&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;What Is PHP?&lt;br /&gt;&lt;/em&gt;&lt;/strong&gt;PHP is the Web development language written by and for Web developers.&lt;br /&gt;PHP stands for PHP: Hypertext Preprocessor. The product was&lt;br /&gt;originally named Personal Home Page Tools, and many people still&lt;br /&gt;think that’s what the acronym stands for. But as it expanded in scope,&lt;br /&gt;a new and more appropriate (albeit GNU-ishly recursive) name was&lt;br /&gt;selected by community vote. PHP is currently in its fifth major&lt;br /&gt;rewrite, called PHP5 or just plain PHP.&lt;br /&gt;PHP is a server-side scripting language, which can be embedded in&lt;br /&gt;HTML or used as a standalone binary (although the former use is&lt;br /&gt;much more common). Proprietary products in this niche are&lt;br /&gt;Microsoft’s Active Server Pages, Macromedia’s ColdFusion, and Sun’s&lt;br /&gt;Java Server Pages. Some tech journalists used to call PHP “the open&lt;br /&gt;source ASP” because its functionality is similar to that of the&lt;br /&gt;Microsoft product—although this formulation was misleading, as&lt;br /&gt;PHP was developed before ASP. Over the past few years, however,&lt;br /&gt;PHP and server-side Java have gained momentum, while ASP has lost&lt;br /&gt;mindshare, so this comparison no longer seems appropriate.&lt;br /&gt;We’ll explore server-side scripting more thoroughly in Chapter 2, but&lt;br /&gt;for the moment you can think of it as a collection of super-HTML tags&lt;br /&gt;or small programs that run inside your Web pages—except on the&lt;br /&gt;server side, before they get sent to the browser. For example, you can&lt;br /&gt;use PHP to add common headers and footers to all the pages on a&lt;br /&gt;site or to store form-submitted data in a database.&lt;br /&gt;&lt;br /&gt;Strictly speaking, PHP has little to do with layout, events, on the fly DOM manipulation, or&lt;br /&gt;really anything about what a Web page looks and sounds like. In fact, most of what PHP does&lt;br /&gt;is invisible to the end user. Someone looking at a PHP page will not necessarily be able to tell&lt;br /&gt;that it was not written purely in HTML, because usually the result of PHP is HTML.&lt;br /&gt;PHP is an official module of Apache HTTP Server, the market-leading free Web server that&lt;br /&gt;runs about 67 percent of the World Wide Web (according to the widely quoted Netcraft Web&lt;br /&gt;server survey). This means that the PHP scripting engine can be built into the Web server&lt;br /&gt;itself, leading to faster processing, more efficient memory allocation, and greatly simplified&lt;br /&gt;maintenance. Like Apache Server, PHP is fully cross-platform, meaning it runs native on several&lt;br /&gt;flavors of Unix, as well as on Windows and now on Mac OS X. All projects under the aegis&lt;br /&gt;of the Apache Software Foundation—including PHP—are open source software.&lt;br /&gt;&lt;strong&gt;&lt;em&gt;What Is MySQL?&lt;br /&gt;&lt;/em&gt;&lt;/strong&gt;MySQL (pronounced My Ess Q El) is an open source, SQL Relational Database Management&lt;br /&gt;System (RDBMS) that is free for many uses (more detail on that later). Early in its history,&lt;br /&gt;MySQL occasionally faced opposition due to its lack of support for some core SQL constructs&lt;br /&gt;such as subselects and foreign keys. Ultimately, however, MySQL found a broad, enthusiastic&lt;br /&gt;user base for its liberal licensing terms, perky performance, and ease of use. Its acceptance&lt;br /&gt;was aided in part by the wide variety of other technologies such as PHP, Java, Perl, Python,&lt;br /&gt;and the like that have encouraged its use through stable, well-documented modules and&lt;br /&gt;extensions. MySQL has not failed to reward the loyalty of these users with the addition of&lt;br /&gt;both subselects and foreign keys as of the 4.1 series.&lt;br /&gt;Databases in general are useful, arguably the most consistently useful family of software&lt;br /&gt;products—the “killer product” of modern computing. Like many competing products, both&lt;br /&gt;free and commercial, MySQL isn’t a database until you give it some structure and form. You&lt;br /&gt;might think of this as the difference between a database and an RDBMS (that is, RDBMS plus&lt;br /&gt;user requirements equals a database).&lt;br /&gt;There’s lots more to say about MySQL, but then again, there’s lots more space in which to&lt;br /&gt;say it.&lt;br /&gt;&lt;strong&gt;&lt;em&gt;The History of PHP&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;Rasmus Lerdorf—software engineer, Apache team member, and international man of&lt;br /&gt;mystery—is the creator and original driving force behind PHP. The first part of PHP was developed&lt;br /&gt;for his personal use in late 1994. This was a CGI wrapper that helped him keep track of&lt;br /&gt;people who looked at his personal site. The next year, he put together a package called the&lt;br /&gt;Personal Home Page Tools (a.k.a. the PHP Construction Kit) in response to demand from users&lt;br /&gt;who had stumbled into his work by chance or word of mouth. Version 2 was soon released&lt;br /&gt;under the title PHP/FI and included the Form Interpreter, a tool for parsing SQL queries.&lt;br /&gt;By the middle of 1997, PHP was being used on approximately 50,000 sites worldwide. It was&lt;br /&gt;clearly becoming too big for any single person to handle, even someone as focused and energetic&lt;br /&gt;as Rasmus. A small core development team now runs the project on the open source&lt;br /&gt;“benevolent junta” model, with contributions from developers and users around the world.&lt;br /&gt;Zeev Suraski and Andi Gutmans, the two Israeli programmers who developed the PHP3 and&lt;br /&gt;PHP4 parsers, have also generalized and extended their work under the rubric of Zend.com&lt;br /&gt;(Zeev, Andi, Zend, get it?).&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;The History of MySQL&lt;br /&gt;&lt;/em&gt;&lt;/strong&gt;Depending on how much detail you want, the history of MySQL can be traced as far back as&lt;br /&gt;1979, when MySQL’s creator, Monty Widenius, worked for a Swedish IT and data consulting&lt;br /&gt;firm, TcX. While at TcX, Monty authored UNIREG, a terminal interface builder that connected&lt;br /&gt;to raw ISAM data stores. In the intervening 15 years, UNIREG served its makers rather well&lt;br /&gt;through a series of translations and extensions to accommodate increasingly large data sets.&lt;br /&gt;In 1994, when TcX began working on Web data applications, chinks in the UNIREG armor,&lt;br /&gt;primarily having to do with application overhead, began to appear. This sent Monty and his&lt;br /&gt;colleagues off to look for other tools. One they inspected rather closely was Hughes mSQL,&lt;br /&gt;a light and zippy database application developed by David Hughes. mSQL possessed the distinct&lt;br /&gt;advantages of being inexpensive and somewhat entrenched in the market, as well as&lt;br /&gt;featuring a fairly well-developed client API. The 1.0 series of mSQL release lacked indexing,&lt;br /&gt;however, a feature crucial to performance with large data stores. Although the 2.0 series of&lt;br /&gt;mSQL would see the addition of this feature, the particular implementation used was not&lt;br /&gt;compatible with UNIREG’s B+-based features. At this point, MySQL, at least conceptually,&lt;br /&gt;was born.&lt;br /&gt;6 Part I . PHP: The Basics&lt;br /&gt;Monty and TcX decided to start with the substantial work already done on UNIREG while&lt;br /&gt;developing a new API that was substantially similar to that used by mSQL, with the exception&lt;br /&gt;of the more effective UNIREG indexing scheme. By early 1995, TcX had a 1.0 version of this&lt;br /&gt;new product ready. They gave it the moniker MySQL and later that year released it under a&lt;br /&gt;combination open source and commercial licensing scheme that allowed continued development&lt;br /&gt;of the product while providing a revenue stream for MySQL AB, the company that&lt;br /&gt;evolved from TcX.&lt;br /&gt;Over the past ten years, MySQL has truly developed into a world class product. MySQL now&lt;br /&gt;competes with even the most feature-rich commercial database applications such as Oracle&lt;br /&gt;and Informix. Additions in the 4.x series have included much-requested features such as&lt;br /&gt;transactions and foreign key support. All this has made MySQL the world’s most used open&lt;br /&gt;source database.&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Reasons to Love PHP and MySQL&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;There are ever so many reasons to love PHP and MySQL. Let us count a few.&lt;br /&gt;Cost&lt;br /&gt;PHP costs you nothing. Zip, zilch, nada, not one red cent. Nothing up front, nothing over the&lt;br /&gt;lifetime of the application, nothing when it’s over. Did we mention that the Apache/PHP/MySQL&lt;br /&gt;combo runs great on cheap, low-end hardware that you couldn’t even think about for&lt;br /&gt;IIS/ASP/SQL Server?&lt;br /&gt;MySQL is a slightly different animal in its licensing terms. Before you groan at the concept of&lt;br /&gt;actually using commercial software, consider that although MySQL is open-source licensed&lt;br /&gt;for many uses, it is not and has never been primarily community-developed software. MySQL&lt;br /&gt;AB is a commercial entity with necessarily commercial interests. Unlike typical open source&lt;br /&gt;projects, where developers often have regular full-time (and paying) day jobs in addition to&lt;br /&gt;their freely given open source efforts, the MySQL developers derive their primary income&lt;br /&gt;from the project. There are still many circumstances in which MySQL can be used for free&lt;br /&gt;(basically anything nonredistributive, which covers most PHP-based projects), but if you&lt;br /&gt;make money developing solutions that use MySQL, consider buying a license or a support&lt;br /&gt;contract. It’s still infinitely more reasonable than just about any software license you will&lt;br /&gt;ever pay for.&lt;br /&gt;For purposes of comparison, Table 1-1 shows some current retail figures for similar products&lt;br /&gt;in the United States. All prices quoted are for a single-processor public Web server with the&lt;br /&gt;most common matching database and development tool; $0 means a no-cost alternative is a&lt;br /&gt;common real-world choice.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Open source software: don’t fear the cheaper&lt;br /&gt;&lt;/em&gt;&lt;/strong&gt;But as the bard so pithily observed, we are living in a material world—where we’ve internalized&lt;br /&gt;maxims such as, “You get what you pay for,” “There’s no such thing as a free lunch,” and&lt;br /&gt;“Things that sound too good to be true usually are.” You (or your boss) may, therefore, have&lt;br /&gt;some lingering doubts about the quality and viability of no-cost software. It probably doesn’t&lt;br /&gt;help that until recently software that didn’t cost money—formerly called freeware, shareware,&lt;br /&gt;or free software—was generally thought to fall into one of three categories:&lt;br /&gt;. Programs filling small, uncommercial niches&lt;br /&gt;. Programs performing grungy, low-level jobs&lt;br /&gt;. Programs for people with bizarre socio-political issues&lt;br /&gt;It’s time to update some stereotypes once and for all. We are clearly in the middle of a sea&lt;br /&gt;change in the business of software. Much (if not most) major consumer software is distributed&lt;br /&gt;without cost today; e-mail clients, Web browsers, games, and even full-service office&lt;br /&gt;suites are all being given away as fast as their makers can whip up Web versions or set up&lt;br /&gt;FTP servers. Consumer software is increasingly seen as a loss-leader, the flower that attracts&lt;br /&gt;the pollinating honeybee—in other words, a way to sell more server hardware, operating&lt;br /&gt;systems, connectivity, advertising, optional widgets, or stock shares. The full retail price of a&lt;br /&gt;piece of software, therefore, is no longer a reliable gauge of its quality or the eccentricity-level&lt;br /&gt;of its user.&lt;br /&gt;On the server side, open source products have come on even stronger. Not only do they&lt;br /&gt;compete with the best commercial stuff; in many cases there’s a feeling that they far exceed&lt;br /&gt;the competition. Don’t take our word for it! Ask IBM, any hardware manufacturer, NASA,&lt;br /&gt;Amazon.com, Rockpointe Broadcasting, Ernie Ball Corporation, the Queen of England, or&lt;br /&gt;the Mexican school system. If your boss still needs to be convinced, further ammunition is&lt;br /&gt;available at www.opensource.org and www.fsf.org.&lt;br /&gt;&lt;strong&gt;&lt;em&gt;The PHP license&lt;br /&gt;&lt;/em&gt;&lt;/strong&gt;The freeness of open source and Free software is guaranteed by a gaggle of licensing schemes,&lt;br /&gt;most famously the GPL (Gnu General Public License) or copyleft. PHP used to be released&lt;br /&gt;under both the GPL and its own license, with each user free to choose between them. This has&lt;br /&gt;recently changed. The program as a whole is now released under its own extremely laissezfaire&lt;br /&gt;PHP license on the model of the BSD license, whereas Zend as a standalone product is&lt;br /&gt;released under the Q Public License (this clause applies only if you unbundle Zend from PHP&lt;br /&gt;and try to sell it).&lt;br /&gt;You can read the fine print about the relevant licenses at these Web sites:&lt;br /&gt;. www.php.net/license/&lt;br /&gt;. www.mysql.com/doc/en/GPL_license.html&lt;br /&gt;. www.troll.no/qpl/annotated.html&lt;br /&gt;Most people get PHP or MySQL via download, but you may have paid for it as part of a Linux&lt;br /&gt;distribution, a technical book, or some other product. In that case, you may now be silently&lt;br /&gt;disputing our assertion that PHP costs nothing. Here’s the twist: Although you can’t require a&lt;br /&gt;fee for most open source software, you can charge for delivering that software in a more convenient&lt;br /&gt;format—such as by putting it on a disk and shipping the disk to the customer. You&lt;br /&gt;can also charge anything the market will bear for being willing to perform certain services or&lt;br /&gt;accept certain risks that the development team may not wish to undertake. For instance, you&lt;br /&gt;&lt;br /&gt;are allowed to charge money for guaranteeing that every copy of the software you distribute&lt;br /&gt;will be virus-free or of reasonable quality, taking on the risk of being sued if a bunch of customers&lt;br /&gt;get bad CD-ROMs that contain hard-drive-erasing viruses.&lt;br /&gt;Usually, open source software users can freely choose the precisely optimal cost-benefit&lt;br /&gt;equation for each particular situation: no cost and no warranties, or expensive but well supported,&lt;br /&gt;or something in between. No organized attempt has been made yet to sell service and&lt;br /&gt;support for PHP (although presumably that will be one of the value-adds of Zend). MySQL AB&lt;br /&gt;does sell support as part some of its licensing packages for the MySQL product. Other open&lt;br /&gt;source products, such as Linux, have companies such as Red Hat standing by to answer your&lt;br /&gt;questions, but the commercialization process is still in the early stages for PHP.&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Ease of Use&lt;br /&gt;&lt;/em&gt;&lt;/strong&gt;PHP is easy to learn, compared to the other ways to achieve similar functionality. Unlike Java&lt;br /&gt;Server Pages or C-based CGI, PHP doesn’t require you to gain a deep understanding of a&lt;br /&gt;major programming language before you can make a trivial database or remote-server call.&lt;br /&gt;Unlike Perl, which has been semijokingly called a “write-only language,” PHP has a syntax&lt;br /&gt;that is quite easy to parse and human-friendly. And unlike ASP.NET, PHP is stable and ready&lt;br /&gt;to solve your problems today.&lt;br /&gt;Many of the most useful specific functions (such as those for opening a connection to an&lt;br /&gt;Oracle database or fetching e-mail from an IMAP server) are predefined for you. A lot of&lt;br /&gt;complete scripts are waiting out there for you to look at as you’re learning PHP. In fact, it’s&lt;br /&gt;entirely possible to use PHP just by modifying freely available scripts rather than starting&lt;br /&gt;from scratch—you’ll still need to understand the basic principles, but you can avoid many&lt;br /&gt;frustrating and time-consuming minor mistakes.&lt;br /&gt;We must mention one caveat: Easy means different things to different people, and for some&lt;br /&gt;Web developers it has come to connote a graphical, drag-and-drop, What You See Is What You&lt;br /&gt;Get development environment. To become truly proficient at PHP, you need to be comfortable&lt;br /&gt;editing HTML by hand. You can use WYSIWYG editors to design sites, format pages, and&lt;br /&gt;insert client-side features before you add PHP functionality to the source code. There are&lt;br /&gt;even ways, which we’ll detail in Chapter 3, to add PHP functions to your favorite editing environment.&lt;br /&gt;It’s not realistic, however, to think you can take full advantage of PHP’s capabilities&lt;br /&gt;without ever looking at source code.&lt;br /&gt;Most advanced PHP users (including most of the development team members) are diehard&lt;br /&gt;hand-coders. They tend to share certain gut-level, subcultural assumptions—for instance,&lt;br /&gt;that hand-written code is beautiful and clean and maximally browser-compatible and therefore&lt;br /&gt;the only way to go—that they do not hesitate to express in vigorous terms. The PHP&lt;br /&gt;community offers help and trades tips mostly by e-mail, and if you want to participate, you&lt;br /&gt;have to be able to parse plain-text source code with facility. Some WYSIWYG users occasionally&lt;br /&gt;ask list members to diagnose their problems by looking at their Web pages instead of&lt;br /&gt;their source code, but this rarely ends well.&lt;br /&gt;That said, let us reiterate that PHP really is easy to learn and write, especially for those with&lt;br /&gt;a little bit of experience in a C-syntaxed programming language. It’s just a little more involved&lt;br /&gt;than HTML but probably simpler than JavaScript and definitely less conceptually complex&lt;br /&gt;than JSP or ASP.NET.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you have no relational database experience or are coming from an environment such as&lt;br /&gt;Microsoft Access, MySQL’s command line interface and lack of implicit structure may at first&lt;br /&gt;seem a little daunting. Again, the word easy is relative. However, MySQL’s increasingly faithful&lt;br /&gt;adherence to the ANSI SQL-92 standard and a comprehensive suite of external client programs,&lt;br /&gt;coupled with graphical administration tools such as PHPMyAdmin and the new&lt;br /&gt;MySQL Control Center, will get even neophyte users up and running quickly compared to&lt;br /&gt;other databases. None of these will substitute for learning a little theory and employing&lt;br /&gt;good design practices, but that subject is for another chapter.&lt;br /&gt;&lt;strong&gt;&lt;em&gt;HTML-embeddedness&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;PHP is embedded within HTML. In other words, PHP pages are ordinary HTML pages that&lt;br /&gt;escape into PHP mode only when necessary. Here is an example:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Hello,&lt;br /&gt;&lt;?php // We have now escaped into PHP mode. // Instead of static variables, the next three lines // could easily be database calls or even cookies; // or they could have been passed from a form. $firstname = ‘Joyce’; $lastname = ‘Park’; $title = ‘Ms.’; echo “$title $lastname”; // OK, we are going back to HTML now. ?&gt;&lt;br /&gt;. We know who you are! Your first name is &lt;?php echo $firstname; ?&gt;.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;You are visiting our site at &lt;?php echo date(‘Y-m-d H: -- i:s’); ?&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Here is a link to your account management page: &lt;a href="”http://www.example.com/accounts/&lt;?php"&gt;/”&gt;&lt;?php echo $firstname; ?&gt;’s account&lt;br /&gt;management page&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;When a client requests this page, the Web server preprocesses it. This means it goes through&lt;br /&gt;the page from top to bottom, looking for sections of PHP, which it will try to resolve. For one&lt;br /&gt;thing, the parser will suck up all assigned variables (marked by dollar signs) and try to plug&lt;br /&gt;them into later PHP commands (in this case, the echo function). If everything goes smoothly,&lt;br /&gt;the preprocessor will eventually return a normal HTML page to the client’s browser&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Stability&lt;br /&gt;&lt;/em&gt;&lt;/strong&gt;The word stable means two different things in this context:&lt;br /&gt;. The server doesn’t need to be rebooted often.&lt;br /&gt;. The software doesn’t change radically and incompatibly from release to release.&lt;br /&gt;To our advantage, both of these connotations apply to both MySQL and PHP.&lt;br /&gt;Apache Server is generally considered the most stable of major Web servers, with a reputation&lt;br /&gt;for enviable uptime percentages. Although it is not the fastest nor the easiest to administer,&lt;br /&gt;once you get it set up, Apache HTTP Server seemingly never crashes. It also doesn’t require&lt;br /&gt;server reboots every time a setting is changed (at least on the Unix side). PHP inherits this&lt;br /&gt;reliability; plus, its own implementation is solid yet lightweight. In a two-and-a-half-month&lt;br /&gt;head-to-head test conducted by the Network Computing labs in October 1999, Apache Server&lt;br /&gt;with PHP handily beat both IIS/Visual Studio and Netscape Enterprise Server/Java for stability&lt;br /&gt;of environment.&lt;br /&gt;PHP and MySQL are also both stable in the sense of feature stability. Their respective development&lt;br /&gt;teams have thus far enjoyed a clear vision of their project and refused to be distracted&lt;br /&gt;by every new fad and ill-thought-out user demand that comes along. Much of the effort goes&lt;br /&gt;into incremental performance improvements, communicating with more major databases, or&lt;br /&gt;adding better session support. In the case of MySQL, the addition of reasonable and expected&lt;br /&gt;new features has hit a rapid clip. For both PHP and MySQL, such improvements have rarely&lt;br /&gt;come at the expense of compatibility. Applications written in PHP3 will function with little or&lt;br /&gt;no revision for PHP4 and 5. And because of the standards-based SQL support, MySQL 3.x&lt;br /&gt;databases are easily moved to more current versions (and most likely always will be).&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Speed&lt;br /&gt;&lt;/em&gt;&lt;/strong&gt;PHP is pleasingly zippy in its execution, especially when compiled as an Apache module on&lt;br /&gt;the Unix side. The MySQL server, once started, executes even very complex queries with&lt;br /&gt;huge result sets in record-setting time.&lt;br /&gt;PHP5 is much faster for almost every use than CGI scripts. There is an unfortunate grain of&lt;br /&gt;truth to the joke that CGI stands for “Can’t Go Instantly.” Although many CGI scripts are written&lt;br /&gt;in C, one of the lowest-level and therefore speediest of the major programming languages,&lt;br /&gt;they are hindered by the fact that each request must spawn an entirely new process after&lt;br /&gt;being handed off from the http daemon. The time and resources necessary for this handoff&lt;br /&gt;and spawning are considerable, and there can be limits to the number of concurrent processes&lt;br /&gt;that can be running at any one time. Other CGI scripting languages such as Perl and&lt;br /&gt;Tcl can be quite slow. Most Web sites have moved away from use of CGI for performance and&lt;br /&gt;security reasons.&lt;br /&gt;Although it takes a slight performance hit by being interpreted rather than compiled, this is&lt;br /&gt;far outweighed by the benefits PHP derives from its status as a Web server module. When&lt;br /&gt;compiled this way, PHP becomes part of the http daemon itself. Because there is no transfer&lt;br /&gt;to and from a separate application server (as there is with ColdFusion, for instance) requests&lt;br /&gt;can be filled with maximum efficiency.&lt;br /&gt;Although no extensive formal benchmarks have compared the two, much anecdotal evidence&lt;br /&gt;and many small benchmarks suggest that PHP is at least as fast as ASP and readily outperforms&lt;br /&gt;ColdFusion or JSP in most applications.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Open source licensing&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;We’ve already dealt with the cost advantages of open source software in the “Cost” section of&lt;br /&gt;this chapter. The other major consequence of these licenses is that the complete source code&lt;br /&gt;for the software must be included in any distribution.&lt;br /&gt;In fact, the Unix version of PHP is released only as source code; so far, the development team&lt;br /&gt;has staunchly resisted countless pleas to distribute official binaries for any of the Unixes. At&lt;br /&gt;first, new users (particularly those also new to Unix) tend to feel that source code is about as&lt;br /&gt;useful as a third leg, and most vastly prefer a nice convenient rpm. But there are both pragmatic&lt;br /&gt;and idealistic reasons for including folders full of pesky .c and .h files.&lt;br /&gt;The most immediate pragmatic advantage is that you can compile your PHP installation with&lt;br /&gt;only the stuff you really need for any given situation. This approach has performance and&lt;br /&gt;security advantages. For instance, you can put in hooks to the database(s) of your choice.&lt;br /&gt;You can recompile as often as you want: maybe when an Apache security release comes out,&lt;br /&gt;or when you wish to support a new database application. By compiling a custom application&lt;br /&gt;specifically suited to your system, or any given snapshot of your system, performance and&lt;br /&gt;stability are increased over their already respectable baseline.&lt;br /&gt;What sets open source software apart from its competitors is not just price but control.&lt;br /&gt;Plenty of consumer software is now given away under various conditions. Careful scrutiny of&lt;br /&gt;the relevant licenses, however, will generally reveal limits as to how the software can be used.&lt;br /&gt;Maybe you can run it at home but not at the office. Perhaps you can load it on your laptop,&lt;br /&gt;but you’re in violation if you use it for business purposes. Or, most commonly, you can use it&lt;br /&gt;for anything you want but forget about looking at the code—much less changing it. There are&lt;br /&gt;even community licenses that force you to donate your improvements to the codebase but&lt;br /&gt;charge you for use of the product at the end!&lt;br /&gt;Don’t even think about coming back with a riposte that involves violating a software&lt;br /&gt;license—we’re covering our ears; we’re not listening! Especially with the explosion in no-cost&lt;br /&gt;software, there’s just no good reason to break the law. Besides, it’s bad karma for software&lt;br /&gt;developers. What goes around, comes around, don’t ya know?&lt;br /&gt;For all their openness, the licenses for MySQL and PHP are quite different. You should not&lt;br /&gt;assume that you understand the MySQL terms simply because you have read the PHP&lt;br /&gt;license. They have many similarities to be sure but also some radically different provisions,&lt;br /&gt;especially when it comes to when you should pay.&lt;br /&gt;Table 1-3 shows examples of the various source and fee positions in today’s software&lt;br /&gt;marketplace.&lt;br /&gt;Table 1-3: Source/Fee Spectrum&lt;br /&gt;Fee Structure Closed Source Controlled Source Open Source&lt;br /&gt;Fee for all uses Macromedia ColdFusion — —&lt;br /&gt;Fee for some uses Corel WordPerfect Sun Java MySQL&lt;br /&gt;No fee for any use Microsoft IE Sun StarOffice GPLed software&lt;br /&gt;Caution&lt;br /&gt;&lt;br /&gt;Genuinely open source software like PHP cannot seek to limit the purposes for which it is&lt;br /&gt;used, the people allowed to use it, or a host of other factors. The most critical of these rights&lt;br /&gt;is the one allowing users to make and distribute any modifications along with the original&lt;br /&gt;software. In the most extreme case, where one or more developers decide to release a separate,&lt;br /&gt;complete version of a piece of software, this practice is referred to as code forking.&lt;br /&gt;If somewhere down the road you develop irreconcilable differences with the PHP development&lt;br /&gt;team, you can take every bit of code they’ve labored over for all these years and use it&lt;br /&gt;as the basis of your own product. You couldn’t call it PHP, and you’d have to include stuff in&lt;br /&gt;your documentation that gave due credit to the authors—the rationale is that source code&lt;br /&gt;distributions make it next to impossible for any single person or group to hijack a program to&lt;br /&gt;the detriment of the community as a whole, because every user always has the power to take&lt;br /&gt;the source and walk.&lt;br /&gt;Users new to the open source model should be aware that this right is also enjoyed by the&lt;br /&gt;developers. At any time, Rasmus, Zend, and company can choose to defect from the community&lt;br /&gt;and put all their future efforts into a commercial or competing product based on PHP. Of&lt;br /&gt;course, the codebase up to this point would still be available to anyone who wanted to pick&lt;br /&gt;up the baton, and for a product as large as PHP that could be a considerable number of volunteer&lt;br /&gt;developers.&lt;br /&gt;This leads to one other oft-forgotten advantage of open source software: You can be pretty&lt;br /&gt;sure the software will be around in a few years, no matter what. In these days of products&lt;br /&gt;with the life spans of morning glories, it’s hard to pick a tool with staying power. Fans of OS/2,&lt;br /&gt;Amiga, NeXT, Newton, Firefly, Netscape, BeOS, Napster, and a host of other once-hot technologies&lt;br /&gt;know the pain of abandonment when a company goes belly-up, decides to stop supporting&lt;br /&gt;a technology, or is sold to a buyer with a new agenda. The open source model reduces the&lt;br /&gt;chances of an ugly emergency port in a couple of years and thus makes long-term planning&lt;br /&gt;more realistic.&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Many extensions&lt;br /&gt;&lt;/em&gt;&lt;/strong&gt;PHP makes it easy to communicate with other programs and protocols. The PHP development&lt;br /&gt;team seems committed to providing maximum flexibility to the largest number of users.&lt;br /&gt;Database connectivity is especially strong, with native-driver support for about 15 of the most&lt;br /&gt;popular databases plus ODBC. In addition, PHP supports a large number of major protocols&lt;br /&gt;such as POP3, IMAP, and LDAP. PHP4 added support for Java and distributed object architectures&lt;br /&gt;(COM and CORBA), making n-tier development a possibility for the first time. PHP5&lt;br /&gt;extends this support even further, offering a fully incorporated GD graphics library and&lt;br /&gt;revamped XML support with DOM and simpleXML.&lt;br /&gt;Most things that PHP does not support are ultimately attributable to closed-source shops on&lt;br /&gt;the other end. For instance, Microsoft has not thus far been eager to cooperate with open&lt;br /&gt;source projects like PHP. Potential users who complain about lack of native Mac OS 9 or .NET&lt;br /&gt;support on the PHP mailing list are simply misinformed about where the fault lies.&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Fast feature development&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;Users of proprietary Web development technologies can sometimes be frustrated by the&lt;br /&gt;glacial speed at which new features are added to the official product standard to support&lt;br /&gt;emerging technologies. With PHP, this is not a problem. All it takes is one developer, a C&lt;br /&gt;compiler, and a dream to add important new functionality. This is not to say that the PHP&lt;br /&gt;&lt;br /&gt;team will accept every random contribution into the official distribution without community&lt;br /&gt;buy-in, but independent developers can and do distribute their own extensions which may be&lt;br /&gt;later folded into the main PHP package in more or less unitary form. For instance, Dan Libby’s&lt;br /&gt;elegant xmlrpc-epi extension was adopted as part of the PHP distribution in version 4.1, a few&lt;br /&gt;months after it was first released as an independent package.&lt;br /&gt;PHP development is also constant and ongoing. Although there are clearly major inflection&lt;br /&gt;points, such as the transition between PHP4 and PHP5, these tend to be most important deep&lt;br /&gt;in the guts of the parser—people were actually working on major extensions throughout the&lt;br /&gt;transition period without critical problems. Furthermore, the PHP group subscribes to the&lt;br /&gt;open source philosophy of “release early, release often,” which gives developers many opportunities&lt;br /&gt;to follow along with changes and report bugs. Compare this release scheme to the&lt;br /&gt;.NET transition, which has left developers with almost a year in which Microsoft is not really&lt;br /&gt;improving IIS but has not yet released a prime-time version of .NET server.&lt;br /&gt;It hasn’t always been the case that MySQL added new features in a timely fashion. It would&lt;br /&gt;probably be fair to say that a significant chunk of PostgreSQL users are former MySQL users&lt;br /&gt;frustrated by the lack of transaction support, for example. However, the 4.0 and 4.1 versions&lt;br /&gt;have remedied this and other inequities. Transactions are in the software today, while subselects&lt;br /&gt;and foreign keys are experimental but coming along nicely.&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Popularity&lt;br /&gt;&lt;/em&gt;&lt;/strong&gt;PHP is fast becoming one of the most popular choices for so-called two-tier development&lt;br /&gt;(Web plus data). Figure 1-2 charts growth since 1999.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Summary&lt;br /&gt;&lt;/em&gt;&lt;/strong&gt;PHP and MySQL, individually or together, aren’t the panacea for every Web development&lt;br /&gt;problem, but they present a lot of advantages. PHP is built by Web developers for Web developers&lt;br /&gt;and supported by a large and enthusiastic community. MySQL is a powerful standardscompliant&lt;br /&gt;RDBMS that comes in at an extremely competitive price point, even more so if you&lt;br /&gt;qualify for free use. Both technologies are clear-cut cases of the community banding together&lt;br /&gt;to address its own needs.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;linda ahmed anwar&lt;br /&gt;sec 11&lt;br /&gt;cs&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34158316-115817624312980068?l=lindaahmed.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lindaahmed.blogspot.com/feeds/115817624312980068/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=34158316&amp;postID=115817624312980068' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34158316/posts/default/115817624312980068'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34158316/posts/default/115817624312980068'/><link rel='alternate' type='text/html' href='http://lindaahmed.blogspot.com/2006/09/httplearning-what-is-php-php-is-web.html' title=''/><author><name>linda</name><uri>http://www.blogger.com/profile/12538669834728464262</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='00880586125148893510'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34158316.post-115817355255523242</id><published>2006-09-13T11:34:00.000-07:00</published><updated>2006-09-13T11:52:32.573-07:00</updated><title type='text'></title><content type='html'>&lt;a href="http://learning"&gt;http://learning little abot MYSQL :&lt;/a&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="color:#cc0000;"&gt;What is MySQL?&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;MySQL is a SQL (Structured Query Language) database server. SQL is the most popular database&lt;br /&gt;language in the world. MySQL is a client server implementation that consists of a server daemon&lt;br /&gt;mysqld and many different client programs/libraries.&lt;br /&gt;The main goals of MySQL are speed and robustness.&lt;br /&gt;The base upon which MySQL is built is a set of routines that have been used in a highly demanding&lt;br /&gt;production environment for many years. While MySQL is currently still in development it already&lt;br /&gt;offers a rich and highly useful function set. &lt;p&gt;&lt;br /&gt;See the ‘CREDITS’ file in the distribution for persons that have been involved in the MySQL&lt;br /&gt;project.&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="color:#cc0000;"&gt;History of MySQL&lt;/span&gt;&lt;br /&gt;&lt;/em&gt;&lt;/strong&gt;We once started off with the intension to use mSQL to connect to our own fast low level (ISAM)&lt;br /&gt;tables. However, after some testing we came to the conclusion that mSQL was not fast or flexible&lt;br /&gt;enough for our needs. This resulted in a new SQL interface to our database but with almost the same&lt;br /&gt;API interface as mSQL. This API was chosen to ease porting of third party code.&lt;br /&gt;It is not perfectly clear where the name MySQL derives from. Our base directory and a large amount&lt;br /&gt;of our libraries and tools have had the prefix ’my’ for well over 10 years. However, Monty’s daughter&lt;br /&gt;(some years younger) is also named My. So which of the two gave its name to MySQL is still a&lt;br /&gt;mystery, even for us.&lt;br /&gt;&lt;em&gt;&lt;span style="color:#ff0000;"&gt;&lt;strong&gt;The main features in MySQL&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/em&gt;Multi-threaded.&lt;br /&gt;C, C++, JAVA, Perl, Python and TCL API’s. See section MySQL client tools and API’s [p 81]&lt;br /&gt;Lots of column types like: signed/unsigned integers 1,2,3,4,8 bytes long, FLOAT, CHAR,&lt;br /&gt;VARCHAR, TEXT, BLOB, DATE, SET and ENUM types. See section Column types. [p 31]&lt;br /&gt;Join optimiser with one-sweep multi-join (all joins made in one pass).&lt;br /&gt;Full function support in the SELECT and WHERE parts. Example: select&lt;br /&gt;column1+column2 from table where column1/column2 &gt; 0&lt;br /&gt;SQL functions are implemented through a very optimised class library and should be as fast as&lt;br /&gt;they can get! Usually there shouldn’t be any memory allocation at all after the query&lt;br /&gt;initialisation.&lt;br /&gt;Full support for SQL GROUP BY and ORDER BY. Support for group functions (SUM, MAX and&lt;br /&gt;MIN).&lt;br /&gt;A privilege and password system with is very flexible and secure. Allows host based verification.&lt;br /&gt;All password traffic on the net is encrypted.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;&lt;em&gt;&lt;strong&gt;What is the current MySQL version?&lt;br /&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;You can always check http://www.tcx.se/ for the latest version of MySQL.&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="color:#ff0000;"&gt;How do I get MySQL?&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;On the Internet, try using a web browser to http://www.tcx.se/&lt;br /&gt;Or ftp to ftp://ftp.sunet.se/pub/unix/databases/relational/mysql/. That isSunet’s (Swedish University&lt;br /&gt;Network) FTP archive in Sweden.&lt;br /&gt;7&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="color:#ff0000;"&gt;Should I get MySQL in source or binary distribution?&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;If you want to read (and/or modify) the C and C++ code that makes up MySQL you should always get&lt;br /&gt;a source distribution. The code is always the ultimate manual. The source distribution also contains&lt;br /&gt;more tests and examples than the binary distribution.&lt;br /&gt;For most people who want to run MySQL on a platform that has binary releases, a binary version of&lt;br /&gt;MySQL is more convenient. However, TcX’s binary release is not compiled in the same way as the&lt;br /&gt;source release so there are some differences in where support files are located.&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="color:#ff0000;"&gt;Which operating systems does MySQL support?&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;We use GNU autoconf so it will be possible to port to all modern systems with working Posix threads&lt;br /&gt;and a C++ compiler. The client code requires C++ but not threads. We use the software ourselves&lt;br /&gt;primarily on Solaris (currently 2.5.1) and some on RedHat Linux 4.2 (kernel 2.0.30).&lt;br /&gt;A working Posix thread library is needed for the server. On Solaris 2.5 we use SUN PThreads (the&lt;br /&gt;native thread support in 2.4 and earlier versions are not good enough) and on Linux we use Linux&lt;br /&gt;Threads by Xavier Leroy @email{Xavier.Leroy@inria.fr}.&lt;br /&gt;A good web page about different thread implementations is http://www.humanfactor.com/pthreads/.&lt;br /&gt;The MySQL distribution includes a patched version of Provenzano’s Pthreads from MIT (see&lt;br /&gt;http://www.mit.edu:8001/people/proven/pthreads.html) in thedistribution. This can be used for some&lt;br /&gt;operating systems that does not have posix threads.&lt;br /&gt;We have also tried to use another user level thread package named FSU Pthreads (see&lt;br /&gt;http://www.informatik.hu-berlin.de/~mueller/pthreads.html). Thisimplementation is being used for the&lt;br /&gt;SCO port.&lt;br /&gt;See the thr_lock and thr_alarm programs in the mysys directory for some tests/examples of these&lt;br /&gt;problems. More information can be found in the ‘PORTING’ file in the distribution.&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="color:#ff0000;"&gt;What languages are supported by MySQL.&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;mysqld can give error messages in the following languages: Czech, Dutch, English (default), French,&lt;br /&gt;German, Norwegian, New Norwegian, Polish, Portuguese, Spanish and Swedish.&lt;br /&gt;To start mysqld with a language use the --language=lang or -L lang switch:&lt;br /&gt;mysqld --language swedish mysqld --language /usr/local/share/swedish&lt;br /&gt;The language files are located (by default) in&lt;br /&gt;‘ mysql_base_dir/share/ LANGUAGE/’&lt;br /&gt;8&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="color:#ff0000;"&gt;How/when will you release updates?&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;We are going to use the following policy when updating MySQL:&lt;br /&gt;Each minor patch will increment the last number in the version string. When there are new features or&lt;br /&gt;minor incompatibilities with previous versions, the second number in the version string will be&lt;br /&gt;incremented.&lt;br /&gt;On the rare occasions when a fatal bug is found that can’t be avoided we will make new binary&lt;br /&gt;releases for Solaris &amp; Linux as soon as possible. Other people may make binary releases for other&lt;br /&gt;systems but probably less frequently.&lt;br /&gt;For other fatal bugs we will make patches available as soon as we have located and fixed the bug.&lt;br /&gt;For non crucial but annoying bugs we will make patches available if they are sent to me,&lt;br /&gt;otherwise we will combine many of them into a bigger patch.&lt;br /&gt;When there are more then about 10 patches we will make a new full source release.&lt;br /&gt;When we have made a lot of changes we will make a new source and binary release. (About once&lt;br /&gt;a month?)&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="color:#ff0000;"&gt;What is UNIREG ?&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;Unireg is our tty interface builder, but it uses a low level connection to our NISAM (with is used by&lt;br /&gt;MySQL) and because of this it is very quick. It has existed since 1979 (on Unix in C since ~1986).&lt;br /&gt;Unireg has the following components:&lt;br /&gt;One table viewer with updates/browsing.&lt;br /&gt;Multi table viewer (with 1 scrolling region)&lt;br /&gt;Table creator. (With lots of column tags you can’t create with MySQL) This is WYSIWYG (for&lt;br /&gt;a tty). You design a screen and Unireg prompts for the column specification.&lt;br /&gt;Report generator&lt;br /&gt;A lot of utilities (Quick export/import of tables to/from text files, analysis of table contents...)&lt;br /&gt;Powerful multi table updates (which we use a lot) with a BASIC like language with LOTS of&lt;br /&gt;functions.&lt;br /&gt;Dynamic languages (at present in Swedish and Finnish). If somebody wants an English version&lt;br /&gt;there are a few files that would have to be translate.&lt;br /&gt;The ability to run updates interactively or in a batch.&lt;br /&gt;Emacs like key definitions with keyboard macros.&lt;br /&gt;All this in a binary of 800k.&lt;br /&gt;The convform utility. Changes .frm and text files between different character sets.&lt;br /&gt;The pack_isam utility. Packs a NISAM table (makes it 50-80% smaller). The table can be read by&lt;br /&gt;MySQL like an ordinary table. Only 1 record has to be decompressed / access. Cannot handle&lt;br /&gt;BLOB:s or updates (yet).&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="color:#ff0000;"&gt;What functionality is missing in MySQL.&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;The following functionality is missing in the current version of MySQL. For the priority of new&lt;br /&gt;extensions you should consult: http://www.tcx.se/TODO&lt;br /&gt;Sub-SELECT. The following will not work in MySQL:&lt;br /&gt;SELECT * from table WHERE id IN (SELECT id from table2)&lt;br /&gt;MySQL only supports INSERT ... SELECT.... Independent sub-SELECTs will be&lt;br /&gt;availably in 3.22.0. One can use the function IN() in other context thought.&lt;br /&gt;MySQL doesn’t yet support sqlSELECT ... INTO TABLE..... Currentlyl MySQL only&lt;br /&gt;supports SELECT ... INTO OUTFILE....&lt;br /&gt;Outer joins. LEFT OUTER JOIN will be availabe in 3.22.0.&lt;br /&gt;Transactions is not supported. MySQL will shortly support atomic operations which is like&lt;br /&gt;transactions without rollback. With atomic operations you can make a bunch of&lt;br /&gt;insert/select/whatever commands and be guaranteed that no other thread will interfere. In this&lt;br /&gt;context you won’t usually need rollback. Currently you can do this with the help of the LOCK&lt;br /&gt;TABLES/UNLOCK TABLES command. See section Lock tables syntax [p 48]&lt;br /&gt;Triggers is not supported. The planed update language will be able to handle stored procedures,&lt;br /&gt;but without triggers. Triggers usually slow down everything, even for queries when they aren’t&lt;br /&gt;needed.&lt;br /&gt;The FOREIGN KEY syntax in MySQL exists only for compatibility with other SQL vendors&lt;br /&gt;CREATE TABLE commands: It doesn’t do anything. The FOREIGN KEY syntax without ON&lt;br /&gt;DELETE .. is mostly used for documentation purposes. Some ODBC applications may uses&lt;br /&gt;this to produce automatic WHERE clauses thought, but this is usually easy to override. FOREIGN&lt;br /&gt;KEY is sometimes used as a constraint check, but this check is in practice unnecessary if one&lt;br /&gt;insert rows in the tables in the right order. In MySQL one can go around the problem that ON&lt;br /&gt;DELETE ... isn’t implement by adding the approative DELETE statement to the application&lt;br /&gt;when one deletes record from a table that has FOREIGN KEY. In practice this is as quick (in&lt;br /&gt;some case quicker) and much more portable than using FOREING KEY Foreign keys is&lt;br /&gt;something that makes life very complicated, because the foreign key definition must be stored in&lt;br /&gt;some database and then the hole ’nice approach’ by using only files that can be moved, copied&lt;br /&gt;and removed will be destroyed. In the near future we will extend FOREIGN KEYS so that the at&lt;br /&gt;least the information will be saved and may be retrieved by mysqldump and ODBC.&lt;br /&gt;MySQL doesn’t support views, but this is on the TODO.&lt;br /&gt;Some other SQL has -- as start comment. MySQL has # as the start comment character, even if&lt;br /&gt;the MySQL command line tool removes all lines that starts with --. MySQL will not support this&lt;br /&gt;degenerated comment style because we have had many problems with automatic generated SQL&lt;br /&gt;queries that has used something like the following code:&lt;br /&gt;20&lt;br /&gt;UPDATE table_name SET credit=credit-!payment!&lt;br /&gt;Where instead of !payment! we automaticly insert the value of the payment. What do you think&lt;br /&gt;will happen when ’payment’ is negative ? Because 1--1 is legal in SQL, we think is terrible that&lt;br /&gt;’--’ means start comment. If you have a sql program in a textfile that contains -- comments you&lt;br /&gt;should use&lt;br /&gt;replace " --" " #" &lt; text-file-with-funny-comments.sql  mysql database.&lt;br /&gt;instead of the normal&lt;br /&gt;mysql database &lt; text-file-with-funny-comments.sql&lt;br /&gt;You can also change the -- to # comments in the command file with:&lt;br /&gt;replace " --" " #" -- text-file-with-funny-comments.sql&lt;br /&gt;and change them back with:&lt;br /&gt;replace " #" " --" -- text-file-with-funny-comments.sql&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="color:#ff0000;"&gt;What standards does MySQL follow?&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;Entry level SQL92. ODBC level 0-2.&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="color:#ff0000;"&gt;What functions exist only for compatibility?&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;GRANT. See section GRANT syntax. (Compatibility function). [p 49] This always succeeds. You&lt;br /&gt;should use the MySQL privilege tables. See section How does the privilege system work? [p 26]&lt;br /&gt;CREATE INDEX. See section CREATE INDEX syntax (Compatibility function). [p 49] This&lt;br /&gt;always succeeds. You should create your index with CREATE TABLE. See section CREATE&lt;br /&gt;TABLE syntax. [p 36] You can also use ALTER TABLE. See section ALTER TABLE syntax [p&lt;br /&gt;37] .&lt;br /&gt;DROP INDEX. See section DROP INDEX syntax (Compatibility function). [p 49] This always&lt;br /&gt;succeeds. You can use ALTER TABLE to drop indexes. See section ALTER TABLE syntax [p&lt;br /&gt;37] .&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="color:#ff0000;"&gt;Limitations of BLOB and TEXT types&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;If you want to GROUP BY or a ORDER BY on a BLOB or TEXT field, you must make the field into a&lt;br /&gt;fixed length object. The standard way to do this is with the SUBSTRING functions. If you don’t do&lt;br /&gt;this only the first max_sort_length (default=1024) will considered when sorting.&lt;br /&gt;SELECT comment from table order by substring(comment,20);&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="color:#ff0000;"&gt;How to go cope without COMMIT-ROLLBACK&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;MySQL doesn’t support COMMIT-ROLLBACK. The problem with COMMIT-ROLLBACK is that&lt;br /&gt;for it to handle this efficiently it would require a completely different table layout than MySQL uses&lt;br /&gt;today. MySQL would also need extra threads that does automatic cleanups on the tables and the disk&lt;br /&gt;usage space needed would be much higher. This would make MySQL about 2-4 times slower than it&lt;br /&gt;is today. One of the reasons that MySQL is so much faster than almost all other SQL databases&lt;br /&gt;21&lt;br /&gt;(typical times are at least 2-3 times faster) is the lack of COMMIT-ROLLBACK.&lt;br /&gt;For the moment, we are much more for implementing the SQL server language (stored procedures).&lt;br /&gt;With this you very seldom really need COMMIT-ROLLBACK besides being able to do many more&lt;br /&gt;things without losing any speed.&lt;br /&gt;Loops that need transactions can normally be coded with the help of LOCK TABLES and one doesn’t&lt;br /&gt;need cursors when one can update records on the fly.&lt;br /&gt;We have transactions and cursors on the TODO but not quite prioritised. If it is implemented it will be&lt;br /&gt;as a option to CREATE TABLE. That means that COMMIT-ROLLBACK will only work on those&lt;br /&gt;tables and only those tables will be slower.&lt;br /&gt;We at TcX have a greater need for a real fast database than a 100% general database. Whenever we&lt;br /&gt;find a way to implement these without any speed loss we will probably do it, but for the moment there&lt;br /&gt;is many more important things to do. Check the TODO for how we prioritise things at the moment.&lt;br /&gt;Customers with extended mail support can alter this slightly, so things may be reprioritised.&lt;br /&gt;The current problem is actually ROLLBACK. Without ROLLBACK you can do anything with LOCK&lt;br /&gt;TABLES. To support ROLLBACK MySQL would had to be changed to store all old records that was&lt;br /&gt;updated and revert everything back to the starting point if ROLLBACK was issued. For simple cases&lt;br /&gt;this isn’t that hard to do (the current isamlog could be used for this), but if one wants to have&lt;br /&gt;ROLLBACK with ALTER/DROP/CREATE TABLE it would make everything much harder to&lt;br /&gt;implement.&lt;br /&gt;To avoid using ROLLBACK one can do:&lt;br /&gt;LOCK TABLES ...&lt;br /&gt;- Test conditions.&lt;br /&gt;- Update if everything is ok.&lt;br /&gt;UNLOCK TABLES.&lt;br /&gt;This is usually much faster, but not always. The only thing this doesn’t handle if someone does a kill&lt;br /&gt;on the process...&lt;br /&gt;One can also use functions to update things in one operation. By doing all updates relatively and/or&lt;br /&gt;only update those fields that actually have changed one can get a very efficient application.&lt;br /&gt;For example, when we are doing updates on some customer information, we only update the customer&lt;br /&gt;data that has changed and only test that not any of the changed data, or data that depends on the&lt;br /&gt;changed data, has changed in the original row. The test for change is down with the WHERE clause in&lt;br /&gt;the UPDATE statement. If the record wasn’t updated we give the client a message: "Some of the data&lt;br /&gt;you have changed has been changed by another user", and then we show the old row versus the new&lt;br /&gt;row in a window. The user can then decide which version of the customer record he should use.&lt;br /&gt;This gives us something like ’column locking’ but actually even better, because we only update some&lt;br /&gt;of the columns with relative information. This means that a typical update statement looks something&lt;br /&gt;&lt;br /&gt;&lt;a href="http://:تعلم"&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34158316-115817355255523242?l=lindaahmed.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lindaahmed.blogspot.com/feeds/115817355255523242/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=34158316&amp;postID=115817355255523242' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34158316/posts/default/115817355255523242'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34158316/posts/default/115817355255523242'/><link rel='alternate' type='text/html' href='http://lindaahmed.blogspot.com/2006/09/httplearning-little-abot-mysql-what-is.html' title=''/><author><name>linda</name><uri>http://www.blogger.com/profile/12538669834728464262</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='00880586125148893510'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry></feed>