Sie sind auf Seite 1von 35

DBMS & Internet Programming Notes

Database Management System


Introduction to Database : A database is a collection of stored operational data used by various applications and/or users by some particular enterprise or by a set of outside authorized applications and authorized users. DataBase Management System : A DataBase Management System (DBMS) is a software system that manages execution of users applications to access and modify database data so that the data security, data integrity, and data reliability is guaranteed for each application and each application is written with an assumption that it is the only application active in the database. What Is Data ? Different view points: A sequence of characters stored in computer memory or storage Interpreted sequence of characters stored in computer memory or storage Interpreted set of objects Database supports a concurrent access to the data File Systems : File is uninterpreted, unstructured collection of information File operations: delete, catalog, create, rename, open, close, read, write, find, Access methods: Algorithms to implement operations along with internal file organization Examples: File of Customers, File of Students; Access method: implementation of a set of operations on a file of students or customers. File Management System Problems : Data redundancy Data Access: New request-new program Data is not isolated from the access implementation Concurrent program execution on the same file Difficulties with security enforcement Integrity issues . ADVANTAGES OF A DBMS: Data independence: Application programs should be as independent as possible from details of data representation and storage. The DBMS can provide an abstract view of the data to insulate application code from such details. client data access: A DBMS utilizes a variety of sophisticated techniques to store and retrieve data efficiently. This feature is especially important if the data is stored on external storage devices. Data integrity and security: If data is always accessed through the DBMS, the DBMS can enforce integrity constraints on the data. For example, before inserting salary information for an employee, the DBMS can check that the department budget is not exceeded. Also, the DBMS can enforce access controls that govern what data is visible to different classes of users. Data administration: When several users share the data, centralizing the administration of data have more significant improvements. Experienced professionals who understand the nature of the data being managed, and how different groups of users use it, can be responsible for organizing the data representation to minimize redundancy and for ne-tuning the storage of the data to make retrieval efficient.

DBMS & Internet Programming Notes Definition 1: A database management system (DBMS) is a general purpose system software facilitating each of the following (with respect to a database):

defining: specifying data types, data organization, and constraints to which the data must conform constructing: the process of storing the data on some medium (e.g., magnetic disk) that is controlled by the DBMS manipulating: querying, updating, report generation Sharing: a database allows multiple users and programs to database concurrently. Protection&security:protection from hardware and software crashes and security from unauthorized access

Definition 2: Database management system is software of collection of small programs to perform certain operation on data and manage the data. Two basic operations performed by the DBMS are: Management of Data in the Database Management of Users associated with the database.

Management of the data means to specify that how data will be stored, structured and accessed in the database. Management of database users means to manage the users in such a way that they can perform any desired operations on the database. DBMS also ensures that a user can not perform any operation for which he is not allowed. And also an authorized user is not allowed to perform any action which is restricted to that user. In General DBMS is a collection of Programs performing all necessary actions associated to a database. Differences of the Database Approach and File Processing System: Database approach vs. File processing approach: Consider an organization/enterprise that is organized as a collection of departments/offices. Each department has certain data processing "needs", many of which are unique to it. In the file processing approach, each department would "own" a collection of relevant data and software applications to manipulate that data. For example, a university's Registrar's Office would maintain (most likely, with the aid of programmers employed by the university's "computer center") data (and programs) relevant to student grades and course enrollments. The A.O Office would maintain data (and programs) regarding fees owed by students for tuition, room and board, etc. One result of this approach is, typically, data redundancy, which not only wastes storage space but also makes it more difficult to keep changing data up-to-date, as a change to one copy of some data item must be made to all of them (called duplication-of-effort). Inconsistency results when one (or more) copies of a datum are changed but not others. (E.g., If you change your address, informing the Department's Office should suffice to ensure that your grades are sent to the right place, but does not guarantee that your next bill will be, as the copy of your address "owned" by the A.Os Office might not have been changed.) Data Levels and their Roles :

DBMS & Internet Programming Notes

Physical corresponds to the first view of data: How data is stored, how is it accessed, how data is modified, is data ordered, how data is allocated to computer memory and/or peripheral devices, how data items are actually represented (ASCI, EBCDIC,) .The physical schema speci es additional storage details. Essentially, the physical schema summarizes how the relations described in the conceptual schema are actually stored on secondary storage devices such as disks and tapes. We must decide what le organizations to use to store the relations, and create auxiliary data structures called indexes to speed up data retrieval operations. Conceptual corresponds to the second view of data: What we want the data to express and what relationships between data w e must express, what story data tells, are all data necessary for the story are discussed. The conceptual schema (sometimes called the logical schema) describes the stored data in terms of the data model of the DBMS. In a relational DBMS, the conceptual schema describes all relations that are stored in the database. In our sample university database, these relations contain information about entities, such as students and faculty, and about relationships, such as students' enrollment in courses. All student entities can be described using records in a Students relation, as we saw earlier. In fact, each collection of entities and each collection of relationships can be described as a relation, leading to the following conceptual schema: Students(sid: string, name: string, login: string, age: integer, gpa: real) Faculty( d: string, fname: string, sal: real) Courses(cid: string, cname: string, credits: integer) Rooms(rno: integer, address: string, capacity: integer) Enrolled(sid: string, cid: string, grade: string) Teaches( d: string, cid: string) Meets In(cid: string, rno: integer, time: string) The choice of relations, and the choice of elds for each relation, is not always obvious, and the process of arriving at a good conceptual schema is called conceptual database design. View corresponds to the third view of data:What part of the data is seen by a specific application .External schemas, which usually are also in terms of the data model of the DBMS, allow data access to be customized (and authorized) at the level of individual users or groups of users. The external schema design is guided by end user requirements. For example, we might ant to allow students to find out the names of faculty members teaching courses, as well as course enrollments. This can be done by defining the following view: Courseinfo(cid: string, fname: string, enrollment: integer)

DBMS & Internet Programming Notes

STRUCTURE OF A DBMS:

When a user issues a query, the parsed query is presented to a query optimizer, which uses information about how the data is stored to produce an effcient execution plan for evaluating the query. An execution plan is a blueprint for evaluating a query, and is usually represented as a tree of relational operators. The code that implements relational operators sits on top of the le and access methods layer. This layer includes a variety of software for supporting the concept of a le, which, in a DBMS, is a collection of pages or a collection of records. This layer typically supports a heap le, or le of unordered pages, as well as indexes. In addition to keeping track of the pages in a le, this layer organizes the information within a page.The les and access methods layer code sits on top of the buer manager, which brings pages in from disk to main memory as needed in response to read requests. The lowest layer of the DBMS software deals with management of space on disk, where the data is stored. Higher layers allocate, deallocate, read, and write pages through (routines provided by) this layer, called the disk space manager. The DBMS supports concurrency and crash recovery by carefully scheduling user requests and maintaining a log of all changes to the database. DBMS components associated with concurrency control and recovery include the transaction manager, which ensures that transactions request and

DBMS & Internet Programming Notes

release locks according to a suitable locking protocol and schedules the execution transactions; the lock manager, which keeps track of requests for locks and grants locks on database objects when they become available; and the recovery manager, which is responsible for maintaining a log, and restoring the system to a consistent state after a crash. The disk space manager, buffer manager, and le and access method layers must interact with these components. Database Users: 1. Database Administrator (DBA): This is the chief administrator, who oversees and manages the database system (including the data and software). Duties include authorizing users to access the database, coordinating/monitoring its use, acquiring hardware/software for upgrades, etc. In large organizations, the DBA might have a support staff. 2. Database Designers: They are responsible for identifying the data to be stored and for choosing an appropriate way to organize it. They also define views for different categories of users. The final design must be able to support the requirements of all the user sub-groups. 3. End Users: These are persons who access the database for querying, updating, and report generation. They are main reason for database's existence! o Casual end users: use database occasionally, needing different information each time; use query language to specify their requests; typically middle- or high-level managers. o Naive/Parametric end users: Typically the biggest group of users; frequently query/update the database using standard canned transactions that have been carefully programmed and tested in advance. Examples: bank tellers check account balances, post withdrawals/deposits Reservation clerks for airlines, hotels, etc., check availability of seats/rooms and make reservations. Shipping clerks (e.g., at DTDC) who use buttons, bar code scanners, etc., to update status of in-transit packages. o Sophisticated end users: engineers, scientists, business analysts who implement their own applications to meet their complex needs. o Stand-alone users: Use "personal" databases, possibly employing a special-purpose (e.g., financial) software package. 4. System Analysts, Application Programmers, Software Engineers: o System Analysts: determine needs of end users, especially naive and parametric users, and develop specifications for canned transactions that meet these needs. o Application Programmers: Implement, test, document, and maintain programs that satisfy the specifications mentioned above. 6-Capabilities/Advantages of using DBMS: These are additional characteristics of dbms. 1. Controlling Redundancy: Data redundancy (such as tends to occur in the "file processing" approach) leads to wasted storage space, duplication of effort (when multiple copies of a datum need to be updated), and a higher likelihood of the introduction of inconsistency. a. On the other hand, redundancy can be used to improve performance of queries. Indexes, for example, are entirely redundant, but help the DBMS in processing queries more quickly. b. A DBMS should provide the capability to automatically enforce the rule that no inconsistencies are introduced when data is updated.

DBMS & Internet Programming Notes

2. Restricting Unauthorized Access: A DBMS should provide a security and authorization subsystem, which is used for specifying restrictions on user accounts. Common kinds of restrictions are to allow read-only access (no updating), or access only to a subset of the data 3. Providing Persistent Storage for Program Objects: Object-oriented database systems make it easier for complex runtime objects (e.g., lists, trees) to be saved in secondary storage so as to survive beyond program termination and to be retrievable at a later time. 4. Providing Storage Structures for Efficient Query Processing: The DBMS maintains indexes (typically in the form of trees and/or hash tables) that are utilized to improve the execution time of queries and updates. (The choice of which indexes to create and maintain is part of physical database design and tuning and is the responsibility of the DBA. a. The query processing and optimization module is responsible for choosing an efficient query execution plan for each query submitted to the system. 5. Providing Backup and Recovery: The subsystem having this responsibility ensures that recovery is possible in the case of a system crash during execution of one or more transactions. 6. Providing Multiple User Interfaces: For example, query languages for casual users, programming language interfaces for application programmers, forms and/or command codes for parametric users, menu-driven interfaces for stand-alone users. 7. Representing Complex Relationships Among Data: A DBMS should have the capability to represent such relationships and to retrieve related data quickly. 8. Enforcing Integrity Constraints: Most database applications are such that the semantics (i.e., meaning) of the data require that it satisfy certain restrictions in order to make sense. Perhaps the most fundamental constraint on a data item is its data type, which specifies the universe of values from which its value may be drawn. (E.g., a Grade field could be defined to be of type Grade_Type, which, say, we have defined as including precisely the values in the set { "A", "A-", "B+", ..., "F" }. a. Another kind of constraint is referential integrity, which says that if the database includes an entity that refers to another one, the latter entity must exist in the database. 9. Permitting Inference and Actions Via Rules: In a deductive database system, one may specify declarative rules that allow the database to infer new data! E.g., Figure out which students are on academic probation. Such capabilities would take the place of application programs that would be used to ascertain such information otherwise. a. Active database systems go one step further by allowing "active rules" that can be used to initiate actions automatically. 10. Potential for enforcing standards: this is very crucial for the success of database applications in large organizations Standards refer to data item names, display formats, screens, report structures, meta-data (description of data) etc. 11. Reduced application development time: incremental time to add each new application is reduced. 12. Flexibility to change data structures: database structure may evolve as new requirements are defined. 13. Availability of up-to-date information very important for on-line transaction systems such as airline, hotel, car reservations. 14. Economies of scale: by consolidating data and applications across departments wasteful overlap of resources and personnel can be avoided. Database System concepts and Architecture: 1-Data Models, Schemas, and Instances:

DBMS & Internet Programming Notes

One fundamental characteristic of the database approach is that it provides some level of data abstraction by hiding details of data storage that are irrelevant to database users. A data model: A set of concepts to describe the structure of a database, the operations for manipulating these structures, and certain constraints that the database should obey.

By structure is meant the data types, relationships, and constraints that should hold for the data. Most data models also include a set of basic operations for specifying retrievals/updates. DATA MODEL BUILDING BLOCKS: Entity 1. Anything about which data are to be collected and stored 2. It is a thing in real world with an independent existance Attribute 1. A characteristic of an entity (e.g. last name) 2. It is a Perticular property that describes the entity Relationship an association among (two or more) entities One-to-many (1:M) relationship Many-to-many (M:N or M:M) relationship One-to-one (1:1) relationship

THE EVOLUTION OF DATA MODELS Hierarchical Network Relational Entity relationship Object oriented

Object-oriented data models include the idea of objects having behavior (i.e., applicable methods) being stored in the database (as opposed to purely "passive" data). According to C.J. Date (one of the leading database experts), a data model is an abstract, selfcontained, logical definition of the objects, operators, and so forth, that together constitute the abstract machine with which users interact. The objects allow us to model the structure of data; the operators allow us to model its behavior. In the relational data model, data is viewed as being organized in two-dimensional tables comprised of tuples of attribute values. This model has operations such as Project, Select, and Join. A data model is not to be confused with its implementation, which is a physical realization on a real machine of the components of the abstract machine that together constitute that model. Logical vs. physical!!

DBMS & Internet Programming Notes

There are other well-known data models that have been the basis for database systems. The best-known models pre-dating the relational model are the hierarchical (in which the entity types form a tree) and the network (in which the entity types and relationships between entities)

Categories Of Data Models (Based On Degree Of Abstractness): High-Level/Conceptual: (e.g., ER model ) provides a view close to the way users would perceive data; uses concepts such as o entity: real-world object or concept (e.g., student, employee, course, department, event) o attribute: some property of interest describing an entity (e.g., height, age, color) o relationship: an interaction among entities (e.g., works-on relationship between an employee and a project) Representational/Implementational: intermediate level of abstractness; example is relational data model (or network). Also called record-based model. Low-Level/Physical: gives details as to how data is stored in computer system, such as record formats, orderings of records, access paths (indexes).

Schemas, Instances, and Database State One must distinguish between the description of a database and the database itself. The former is called the database schema, which is specified during design and is not expected to change often. The actual data stored in the database probably changes often. The data in the database at a particular time is called the state of the database, or a snapshot. Schema is also called intension. State is also called extension.

2-Three-Schema Architecture: This idea was first described by the ANSI/SPARC committee in late 1970's. The goal is to separate (i.e., insert layers of "insulation" between) user applications and the physical database. It is an ideal that few real-life DBMS's achieve fully.

Internal/Physical Schema: describes the physical storage structure (using a low-level data model) Conceptual Schema: describes the (logical) structure of the whole database for a community of users. Hides physical storage details, concentrating upon describing entities, data types,

DBMS & Internet Programming Notes

relationships, user operations, and constraints. Can be described using either high-level or implementational data model. External Schema (or user views): Each such schema describes part of the database that a particular category of users is interested in, hiding rest of database. Can be described using either high-level or implementational data model. (In practice, usually described using same model as is the conceptual schema.)

Users (including application programs) submit queries that are expressed with respect to the external level. It is the responsibility of the DBMS to transform such a query into one that is expressed with respect to the internal level (and to transform the result, which is at the internal level, into its equivalent at the external level). Example: Select students with GPA > 3.5. Q: How is this accomplished? A: By virtue of mappings between the levels: external/conceptual mapping (providing logical data independence) conceptual/internal mapping (providing physical data independence)

Data independence is the capacity to change the schema at one level of the architecture without having to change the schema at the next higher level. We distinguish between logical and physical data independence according to which two adjacent levels are involved. The former refers to the ability to change the conceptual schema without changing the external schema. The latter refers to the ability to change the internal schema without having to change the conceptual. Logical Data Independence: The capacity to change the conceptual schema without having to change the external schemas and their associated application programs. Physical Data Independence: The capacity to change the internal schema without having to change the conceptual schema. For an example of physical data independence, suppose that the internal schema is modified (because we decide to add a new index, or change the encoding scheme used in representing some field's value, or stipulate that some previously unordered file must be ordered by a particular field ). Then we can change the mapping between the conceptual and internal schemas in order to avoid changing the conceptual schema itself. Not surprisingly, the process of transforming data via mappings can be costly (performance-wise), which is probably one reason that real-life DBMS's don't fully implement this 3-schema architecture. 3-DBMS Languages : DDL: Data definition (conceptual schema, possibly internal/external) language Used by the DBA and database designers to specify the conceptual schema of a database.

DBMS & Internet Programming Notes

10

In many DBMSs, the DDL is also used to define internal and external schemas (views). In some DBMSs, separate storage definition language (SDL) and view definition language (VDL) are used to define internal and external schemas.

SDL: Storage definition (internal schema) language SDL is typically realized via DBMS commands provided to the DBA and database designers

VDL: View definition (external schema) language DML: Data manipulation (retrieval, update) language o High-Level or Non-procedural Languages: These include the relational language SQL May be used in a standalone way or may be embedded in a programming language Low Level or Procedural Languages: These must be embedded in a programming language

Entity-Relationship Model
Entity-Relationship (ER) Model: Our focus now is on the second phase, conceptual design, for which The Entity-Relationship (ER) Model is a popular high-level conceptual data model. In the ER model, the main concepts are entity, attribute, and relationship. Entities and Attributes Entity: An entity represents some "thing" (in the miniworld) that is of interest to us, i.e., about which we want to maintain some data. An entity could represent a physical object (e.g., house, person, automobile, widget) or a less tangible concept (e.g., company, job, academic course). Attribute: An entity is described by its attributes, which are properties characterizing it. Each attribute has a value drawn from some domain (set of meaningful values). Example: A STUDENT entity might be described by RNO, Name, BirthDate, etc., attributes, each having a particular value. What distinguishes an entity from an attribute is that the latter is strictly for the purpose of describing the former and is not, in and of itself, of interest to us. It is sometimes said that an entity has an independent existence, whereas an attribute does not. In performing data modeling, however, it is not always clear whether a particular concept deserves to be classified as an entity or "only" as an attribute. We can classify attributes along these dimensions: simple/atomic vs. composite single-valued vs. multi-valued (or set-valued)

DBMS & Internet Programming Notes stored vs. derived

11

A composite attribute is one that is composed of smaller parts. An atomic attribute is indivisible or indecomposable. A simple/atomic attributes that are not divisible Example 1: A BirthDate attribute can be viewed as being composed of (sub-)attributes for month, day, and year. Example 2: An Address attribute can be viewed as being composed of (sub-)attributes for street address, city, state, and zip code. A street address can itself be viewed as being composed of a number, street name, and apartment number. As this suggests, composition can extend to a depth of two (as here) or more.

To describe the structure of a composite attribute, one can draw a tree , it is customary to write its name followed by a parenthesized list of its sub-attributes. For the examples mentioned above, we would write BirthDate(Month,Day,Year) Address(StreetAddr(StrNum, StrName, AptNum), City, State, Zip)

Single- vs. multi-valued Single valued: Most of attributes have single value for particulary entity. Multi valued: Attrbute can have set of values for some entities attribute: Consider a PERSON entity. The person it represents has (one) SSN, (one) date of birth, (one, although composite) name, etc. But that person may have zero or more academic degrees, dependents, or (if the person is a male living in tenali) spouses! How can we model this via attributes AcademicDegrees, Dependents, and Spouses? One way is to allow such attributes to be multi-valued , which is to say that we assign to them a (possibly empty) set of values rather than a single value. To distinguish a multi-valued attribute from a single-valued one, it is customary to enclose the former within curly braces (which makes sense, as such an attribute has a value that is a set, and curly braces are traditionally used to denote sets). Using the PERSON example from above, we would depict its structure in text as PERSON(SSN, Name, BirthDate(Month, Day, Year), { AcademicDegrees(School, Level, Year) }, { Dependents }, ...)

DBMS & Internet Programming Notes

12

Here we have taken the liberty to assume that each academic degree is described by a school, level (e.g., B.S., Ph.D.), and year. Thus, AcademicDegrees is not only multi-valued but also composite. We refer to an attribute that involves some combination of multi-valuedness and compositeness as a complex attribute. A more complicated example of a complex attribute is AddressPhone. This attribute is for recording data regarding addresses and phone numbers of a business. The structure of this attribute allows for the business to have several offices, each described by an address and a set of phone numbers that ring into that office. Its structure is given by { AddressPhone( { Phone(AreaCode, Number) }, Address(StrAddr(StrNum, StrName, AptNum), City, State, Zip)) } Stored vs. derived attribute: Perhaps independent and derivable would be better terms for these (or nonredundant and redundant). In any case, a derived attribute is one whose value can be calculated from the values of other attributes, and hence need not be stored. Example: Age can be calculated from BirthDate, assuming that the current date is accessible. BirthDate attribute is called stored attributes The Null value: In some cases a particular entity might not have an applicable value for a particular attribute. Or that value may be unknown. Or, in the case of a multi-valued attribute, the appropriate value might be the empty set. Example: The attribute DateOfDeath is not applicable to a living person and its correct value may be unknown for some persons who have died. In such cases, we use a special attribute value, called null. There has been some argument in the database literature about whether a different approach (such as having distinct values for not applicable and unknown) would be superior. 3-Entity Types, Entity Sets, Keys, and Domains Above we mentioned the concept of a PERSON entity, i.e., a representation of a particular person via the use of attributes such as Name, Sex, etc. Chances are good that, in a database in which one such entity exists, we will want many others of the same kind to exist also, each of them described by the same collection of attributes. Of course, the values of those attributes will differ from one entity to another (e.g., one person will have the name "keerthy" and another will have the name "sai"). Just as likely is that we will want our database to store information about other kinds of entities, such as business transactions or academic courses, which (of course) will be described by entirely different collections of attributes. This illustrates the distinction between entity types and entity instances. An entity type serves as a template for a collection of entity instances, all of which are described by the same collection of attributes. That is, an entity type is analogous to a class in object-oriented programming and an entity instance is analogous to a particular object (i.e., instance of a class). In ER modeling, we deal only with entity types, not with instances or occurrences. In an ER diagram, each entity type is denoted by a rectangular box. An entity set is the collection of all entities of a particular type that exist, in a database, at some moment in time.

DBMS & Internet Programming Notes

13

Relationship Sets:A relationship is an association among several entities. A relationship set is a set of relationships of the same type. Mapping Cardinalities:Mapping cardinalities, or cardinality ratios, express the number of entities to which another entity can be associated via a relationship set. Mapping cardinalities are most useful in describing binary relationship sets, although they can contribute to the description of relationship sets that involve more than two entity sets. One to one. An entity in A is associated with at most one entity in B, and an entity in B is associated with at most one entity in A. One to many. An entity in A is associated with any number (zero or more) of entities in B. An entity in B, however, can be associated with at most one entity in A. Many to one. An entity in A is associated with at most one entity in B. An entity in B, however, can be associated with any number (zero or more) of entities in A. Many to many. An entity in A is associated with any number (zero or more) of entities in B, and an entity in B is associated with any number (zero or more) of entities in A.

Keys: A key allows us to identify a set of attributes that suffice to distinguish entities from each other. Keys also help uniquely identify relationships, and thus distinguish relationships from each other. superkey:A superkey is a set of one or more attributes that, taken collectively, allow us to identify uniquely an entity in the entity set. For example, the customer-id attribute of the entity set customer is sufficient to distinguish one customer entity from another. Thus, customer-id is a superkey. Similarly, the combination of customer-name and customer-id is a superkey for the entity set customer. The customer-name attribute of customer is not a superkey, because several people might have the same name. candidate key:minimal superkeys are called candidate keys.If K is a superkey, then so is any superset of K. We are often interested in superkeys for which no proper subset is a superkey.It is possible that several distinct sets of attributes could serve as a candidate key.Suppose that a combination of customer-name and customer-street is sufficient to distinguish among members of the customer entity set. Then, both {customer-id} and {customer-name, customer-street} are candidate keys. Although the attributes customerid and customer-name together can distinguish customer entities, their combination does not form a candidate key, since the attribute customer-id alone is a candidate key. primary key:which denotes the unique identity is called as primary key.primary key to denote a candidate key that is chosen by the database designer as the principal means of identifying entities within an entity set. A key (primary, candidate, and super) is a property of the entity set, rather than of the individual entities. Any two individual entities in the set are prohibited from having the same value on the key attributes at the same time. The designation of a key represents a constraint in the real-world enterprise being modeled. Weak Entity Sets:An entity set may not have sufficient attributes to form a primary key. Such an entity set is termed a weak entity set. An entity set that has a primary key is termed a strong entity set.

Constraints on Relationship Types: Often, in order to make a relationship type be an accurate model of the miniworld concepts that it is intended to represent, we impose certain constraints that limit the possible corresponding relationship sets. (That is, a constraint may make "invalid" a particular set of instances for a relationship type.)

DBMS & Internet Programming Notes

14

There are two main kinds of relationship constraints (on binary relationships). For illustration, let R be a relationship set consisting of ordered pairs of instances of entity types A and B, respectively.

Cardinality Ratio: o 1:1 (one-to-one): Under this constraint, no instance of A may particpate in more than one instance of R; similarly for instances of B. In other words, if (a1, b1) and (a2, b2) are (distinct) instances of R, then neither a1 = a2 nor b1=b2. Example: Our informal description of COMPANY says that every department has one employee who manages it. If we also stipulate that an employee may not (simultaneously) play the role of manager for more than one department, it follows that MANAGES is 1:1. o 1:N (one-to-many): Under this constraint, no instance of B may participate in more than one instance of R, but instances of A are under no such restriction. In other words, if (a1, b1) and (a2, b2) are (distinct) instances of R, then it cannot be the case that b1 = b2. Example: CONTROLS is 1:N because no project may be controlled by more than one department. On the other hand, a department may control any number of projects, so there is no restriction on the number of relationship instances in which a particular department instance may participate. For similar reasons, SUPERVISES is also 1:N. o N:1 (many-to-one): This is just the same as 1:N but with roles of the two entity types reversed. Example: WORKS_FOR and DEPENDS_ON are N:1. o M:N (many-to-many): Under this constraint, there are no restrictions. (Hence, the term applies to the absence of a constraint!) Example: WORKS_ON is M:N, because an employee may work on any number of projects and a project may have any number of employees who work on it.

Introduction to SQL SQL is a standard language for accessing and manipulating databases. SQL stands for Structured Query Language SQL lets you access and manipulate databases SQL is an ANSI (American National Standards Institute) standard

SQL FEATURES SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL can can can can can can can can can can execute queries against a database retrieve data from a database insert records in a database update records in a database delete records from a database create new databases create new tables in a database create stored procedures in a database create views in a database set permissions on tables, procedures, and views

ALTHOUGH SQL IS AN ANSI (AMERICAN NATIONAL STANDARDS INSTITUTE) STANDARD, THERE ARE MANY DIFFERENT VERSIONS OF THE SQL LANGUAGE. HOWEVER, TO BE COMPLIANT WITH THE ANSI STANDARD, THEY ALL SUPPORT AT LEAST THE MAJOR COMMANDS (SUCH AS SELECT, UPDATE, DELETE, INSERT, WHERE) IN A SIMILAR MANNER. USING SQL IN YOUR WEB SITE To build a web site that shows some data from a database, you will need the following: An RDBMS database program (i.e. MS Access, SQL Server, MySQL) A server-side scripting language, like PHP or ASP

DBMS & Internet Programming Notes SQL HTML / CSS

15

RDBMS RDBMS stands for Relational Database Management System. RDBMS is the basis for SQL, and for all modern database systems like MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access. The data in RDBMS is stored in database objects called tables. A table is a collections of related data entries and it consists of columns and rows. SQL Syntax Database Tables A database most often contains one or more tables. Each table is identified by a name (e.g. "Customers" or "Orders"). Tables contain records (rows) with data. SQL STATEMENTS Most of the actions you need to perform on a database are done with SQL statements. The following SQL statement will select all the records in the table: SELECT * FROM Table-Name Some database systems require a semicolon at the end of each SQL statement. Semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server. SQL DML AND DDL SQL can be divided into two parts: The Data Manipulation Language (DML) and the Data Definition Language (DDL). The query and update commands form the DML part of SQL: SELECT - extracts data from a database UPDATE - updates data in a database DELETE - deletes data from a database INSERT INTO - inserts new data into a database

The DDL part of SQL permits database tables to be created or deleted. It also define indexes (keys), specify links between tables, and impose constraints between tables. The most important DDL statements in SQL are: CREATE DATABASE - creates a new database ALTER DATABASE - modifies a database CREATE TABLE - creates a new table ALTER TABLE - modifies a table DROP TABLE - deletes a table CREATE INDEX - creates an index (search key) DROP INDEX - deletes an index

SQL SELECT Statement The SQL SELECT Statement The SELECT statement is used to select data from a database. The result is stored in a result table, called the result-set. SQL SELECT Syntax

DBMS & Internet Programming Notes SELECT column_name(s) FROM table_name And SELECT * FROM table_name SQL SELECT DISTINCT Statement The SQL SELECT DISTINCT Statement

16

In a table, some of the columns may contain duplicate values. This is not a problem, however, sometimes you will want to list only the different (distinct) values in a table. The DISTINCT keyword can be used to return only distinct (different) values. SQL SELECT DISTINCT Syntax SELECT DISTINCT column_name(s) FROM table_name SQL WHERE Clause The WHERE clause is used to extract only those records that fulfill a specified criterion. SQL WHERE Syntax SELECT column_name(s) FROM table_name WHERE column_name operator value QUOTES AROUND TEXT FIELDS SQL uses single quotes around text values (most database systems will also accept double quotes). Although, numeric values should not be enclosed in quotes. For text values: SELECT * FROM Persons WHERE FirstName='Tove'

For numeric values: SELECT * FROM Persons WHERE Year=1965 Operators Allowed in the WHERE Clause With the WHERE clause, the following operators can be used: Operator = <> > < >= <= BETWEEN LIKE IN Equal Not equal Greater than Less than Greater than or equal Less than or equal Between an inclusive range Search for a pattern If you know the exact value you want to return for at least one of the columns Description

In some versions of SQL the <> operator may be written as != SQL AND & OR Operators The AND & OR operators are used to filter records based on more than one condition.

DBMS & Internet Programming Notes THE AND & OR OPERATORS

17

The AND operator displays a record if both the first condition and the second condition is true. The OR operator displays a record if either the first condition or the second condition is true. SQL ORDER BY Keyword The ORDER BY keyword is used to sort the result-set by a specified column. The ORDER BY keyword sort the records in ascending order by default. If you want to sort the records in a descending order, you can use the DESC keyword. SQL ORDER BY Syntax SELECT column_name(s) FROM table_name ORDER BY column_name(s) ASC|DESC SQL INSERT INTO Statement The INSERT INTO statement is used to insert new records in a table. It is possible to write the INSERT INTO statement in two forms. The first form doesn't specify the column names where the data will be inserted, only their values: INSERT INTO table_name VALUES (value1, value2, value3,...) The second form specifies both the column names and the values to be inserted: INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...)

THE UPDATE STATEMENT The UPDATE statement is used to update existing records in a table. SQL UPDATE Syntax UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value Note: Notice the WHERE clause in the UPDATE syntax. The WHERE clause specifies which record or records that should be updated. If you omit the WHERE clause, all records will be updated! THE DELETE STATEMENT The DELETE statement is used to delete rows in a table. SQL DELETE Syntax DELETE FROM table_name

DBMS & Internet Programming Notes WHERE some_column=some_value Note: Notice the WHERE clause in the DELETE syntax. The WHERE clause specifies which record or records that should be deleted. If you omit the WHERE clause, all records will be deleted! DELETE ALL ROWS It is possible to delete all rows in a table without deleting the table. This means that the table structure, attributes, and indexes will be intact: DELETE FROM table_name or DELETE * FROM table_name Be very careful when deleting records. You cannot undo this statement! SQL DROP INDEX, DROP TABLE, and DROP DATABASE Indexes, tables, and databases can easily be deleted/removed with the DROP statement. THE DROP TABLE STATEMENT -THE DROP TABLE STATEMENT IS USED TO DELETE A TABLE. DROP TABLE table_name

18

THE DROP DATABASE STATEMENT The DROP DATABASE statement is used to delete a database. DROP DATABASE database_name

THE TRUNCATE TABLE STATEMENT What if we only want to delete the data inside the table, and not the table itself? Then, use the TRUNCATE TABLE statement: TRUNCATE TABLE table_name SQL ALTER TABLE Statement The ALTER TABLE Statement The ALTER TABLE statement is used to add, delete, or modify columns in an existing table. SQL ALTER TABLE Syntax- To add a column in a table, use the following syntax: ALTER TABLE table_name ADD column_name datatype

DBMS & Internet Programming Notes To delete a column in a table, use the following syntax (notice that some database systems don't allow deleting a column): ALTER TABLE table_name DROP COLUMN column_name To change the data type of a column in a table, use the following syntax: ALTER TABLE table_name ALTER COLUMN column_name datatype SQL IN Operator The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE column_name IN (value1,value2,...) SQL BETWEEN Operator The BETWEEN operator is used in a WHERE clause to select a range of data between two values. SQL BETWEEN Syntax SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2

19

SQL NOT NULL CONSTRAINT The NOT NULL constraint enforces a column to NOT accept NULL values. The NOT NULL constraint enforces a field to always contain a value. This means that you cannot insert a new record, or update a record without adding a value to this field. The following SQL enforces the "P_Id" column and the "LastName" column to not accept NULL values: CREATE TABLE Persons ( P_Id int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255) )

DBMS & Internet Programming Notes SQL UNIQUE CONSTRAINT

20

The UNIQUE constraint uniquely identifies each record in a database table. The UNIQUE and PRIMARY KEY constraints both provide a guarantee for uniqueness for a column or set of columns. A PRIMARY KEY constraint automatically has a UNIQUE constraint defined on it. Note that you can have many UNIQUE constraints per table, but only one PRIMARY KEY constraint per table. SQL Server / Oracle / MS Access: CREATE TABLE Persons ( P_Id int NOT NULL UNIQUE, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255) )

TO DROP A UNIQUE CONSTRAINT To drop a UNIQUE constraint, use the following SQL:SQL Server / Oracle / MS Access: ALTER TABLE Persons DROP CONSTRAINT uc_PersonID SQL PRIMARY KEY Constraint SQL PRIMARY KEY Constraint The PRIMARY KEY constraint uniquely identifies each record in a database table. Primary keys must contain unique values. A primary key column cannot contain NULL values. Each table should have a primary key, and each table can have only one primary key. SQL PRIMARY KEY CONSTRAINT ON CREATE TABLE The following SQL creates a PRIMARY KEY on the "P_Id" column when the "Persons" table is created: SQL Server / Oracle / MS Access: CREATE TABLE Persons ( P_Id int NOT NULL PRIMARY KEY, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255) )

SQL PRIMARY KEY CONSTRAINT ON ALTER TABLE To create a PRIMARY KEY constraint on the "P_Id" column when the table is already created, use the following SQL:

DBMS & Internet Programming Notes MySQL / SQL Server / Oracle / MS Access: ALTER TABLE Persons ADD PRIMARY KEY (P_Id)

21

TO DROP A PRIMARY KEY CONSTRAINT To drop a PRIMARY KEY constraint, use the following SQL: SQL Server / Oracle / MS Access: ALTER TABLE Persons DROP CONSTRAINT pk_PersonID

DBMS & Internet Programming Notes

22

Introduction Internet
The Internet is a global system of interconnected computer networks to serve billions of users worldwide. It is a network of networks that consists of millions of private, public, academic, business, and government networks, of local to global scope, that are linked by a broad array of electronic, wireless and optical networking technologies. The Internet carries an extensive range of information resources and services, such as the inter-linked hypertext documents of the World Wide Web (WWW) and the infrastructure to support email. Most traditional communications media including telephone, music, film, and television are reshaped or redefined by the Internet, giving birth to new services such as Voice over Internet Protocol (VoIP) and Internet Protocol Television (IPTV). Newspaper, book and other print publishing are adapting to Web site technology, or are reshaped into blogging and web feeds. The Internet has enabled or accelerated new forms of human interactions through instant messaging, Internet forums, and social networking. Online shopping has boomed both for major retail outlets and small artisans and traders. Business-to-business and financial services on the Internet affect supply chains across entire industries. Internet is a short form of the technical term internetwork, the result of interconnecting computer networks with special gateways or routers. The Internet is also often referred to as the Net. The terms Internet and World Wide Web are often used in everyday speech without much distinction. However, the Internet and the World Wide Web are not one and the same. The Internet establishes a global data communications system between computers. In contrast, the Web is one of the services communicated via the Internet. It is a collection of interconnected documents and other resources, linked by hyperlinks and URLs.

Internet history and organization The groundwork for Internet was created as early as in 1957. That year USSR launched the first satellite, Sputnik. To establish lead in military science and technology the US Department of Defence formed the Advanced Research Projects Agency, commonly known as ARPA. Later in the 60s, ARPA started to study networks and how it could be used to spread information. In 1969 the first few networks were connected. The first system to send e-mail across a distributed network was developed 1971 by Ray Tomlinson and the telnet (allowing users to login on remote computers) specifications arrived one year later. The first drafts for a networked called Ethernet were created in 73 and a year later there was a detailed description of the Transmission Control Protocol. The Usenet newsgroups were created in 1979 and in 1982 Department of Defence declared TCP/IP to be standard. At this time the number of hosts connected was very low, in 1984 it broke the 1000 boundary. Three years later that number had changed to 10000, but we are still far from the Internet explosion. Most of this all happened before computers were widely spread, IBM released its first PC, based on Intels 8088 processor in 1981. The Pentium processor family that currently is being phased out arrived in 1994. The users connected to the Internet at this time were researchers and students, connected by university networks. A worm that infected computers on the Internet with a program that took up system resources (like memory) created a need for some sort of team that would try to find solutions to make such issues less dangerous. The team was called Computer Emergency Rescue Team (CERT). They work by writing advisories and reports on how to avoid problems. What most people tend to define the Internet as, is the web. The World-Wide Web standard was created in 1991 by CERN and the predecessor to Netscape Navigator, Mosaic saw light two years

DBMS & Internet Programming Notes

23

later. Common people started to get Internet access in 1994-95, its around those years the numbers of hosts, domains and networks started to increase rapidly. Yet only a small amount of the earths population is connected.

COMMON USES / APPLICATION OF THE INTERNET E-MAIL: The concept of sending electronic text messages between parties in a way analogous to mailing letters or memos predates the creation of the Internet. Every day, the citizens of the Internet send each other billions of e-mail messages. e-mail has become an extremely popular communication tool. An e-mail message has always been nothing more than a simple text message a piece of text sent to a recipient. In the beginning and even today, e-mail messages tend to be short pieces of text, although the ability to add attachments now makes many e-mail messages quite long. Even with attachments, however, e-mail messages continue to be text messages. E-mail Clients You have probably already received several e-mail messages today. To look at them, you use some sort of e-mail client. Many people use well-known stand-alone clients like Microsoft Outlook, Outlook Express, Eudora or Pegasus. People who subscribe to free email services like Hotmail or Yahoo use an e-mail client that appears in a Web page. No matter which type of client you are using, it generally does four things: It shows you a list of all of the messages in your mailbox by displaying the message headers. The header shows you who sent the mail, the subject of the mail and may also show the time and date of the message and the message size. It lets you select a message header and read the body of the e-mail message. It lets you create new messages and send them. You type in the e-mail address of the recipient and the subject for the message, and then type the body of the message. Most e-mail clients also let you add attachments to messages you send and save the attachments from messages you receive. THE WORLD WIDE WEB: (Access to information) Through keyword-driven Internet research using search engines, like Google, millions worldwide have easy, instant access to a vast and diverse amount of online information. Compared to encyclopedias and traditional libraries, the World Wide Web has enabled a sudden and extreme decentralization of information and data. REMOTE ACCESS The Internet allows computer users to connect to other computers and information stores easily, wherever they may be across the world. This is encouraging new ways of working from home, collaboration and information sharing in many industries. For example: An accountant sitting at home can audit the books of a company based in another country, on a server situated in a third country that is remotely maintained by IT specialists in a fourth. These accounts could have been created by home-working bookkeepers, in other remote locations, based on information e-mailed to them from offices all over the world. An office worker away from his desk, perhaps the other side of the world on a business trip or a holiday, can open a remote desktop session into his normal office PC using a secure Virtual Private Network (VPN) connection via the Internet. This gives him complete access to all his normal files and data, including e-mail and other applications, while he is away. COLLABORATION The low-cost and nearly instantaneous sharing of ideas, knowledge, and skills has made collaborative work dramatically easier. Not only can a group cheaply communicate and test, but the wide reach of

DBMS & Internet Programming Notes

24

the Internet allows such groups to easily form in the first place, even among niche interests. An example of this is the free software movement in software development which produced GNU and Linux from scratch and has taken over development of Mozilla and OpenOffice.org (formerly known as Netscape Communicator and StarOffice). FILE SHARING: A computer file can be e-mailed to customers, colleagues and friends as an attachment. It can be uploaded to a Web site or FTP server for easy download by others. It can be put into a "shared location" or onto a file server for instant use by colleagues. These simple features of the Internet, over a world-wide basis, are changing the basis for the production, sale, and distribution of anything that can be reduced to a computer file for transmission. This includes all manner of office documents, publications, software products, music, photography, video, animations, graphics and the other arts. STREAMING MEDIA Many existing radio and television broadcasters provide Internet 'feeds' of their live audio and video streams (for example, the BBC). They may also allow time-shift viewing or listening such as Preview, Classic Clips and Listen Again features. These providers have been joined by a range of pure Internet 'broadcasters' who never had onair licenses. Podcasting is a variation on this theme, where usually audiomaterial is first downloaded in full and then may be played back on a computer. Webcams can be seen as an even lower-budget extension of this phenomenon. Internet users can watch animals around an African waterhole, ships in the Panama Canal, the traffic at a local roundabout or their own premises, live and in real time. Video chat rooms, video conferencing, and remote controllable webcams are also popular. VOICE TELEPHONY (VOIP) VoIP stands for Voice over IP, where IP refers to the Internet Protocol that underlies all Internet communication. This phenomenon began as an optional two-way voice extension to some of the Instant Messaging systems that took off around the year 2000. In recent years many VoIP systems have become as easy to use and as convenient as a normal telephone. The benefit is that, as the Internet carries the actual voice traffic, VoIP can be free or cost much less than a normal telephone call, especially over long distances and especially for those with always-on ADSL or DSL Internet connections. Eg: Sify has started a business by which one can make ISD calls at a cheaper rate. Thus VoIP is maturing into a viable alternative to traditional telephones. Interoperability between different providers has improved and the ability to call or receive a call from a traditional telephone is available. Simple inexpensive VoIP modems are now available that eliminate the need for a PC.Voice quality can still vary from call to call but is often equal to and can even exceed that of traditional calls. Eg Skype has the best voice quality as compared to any other VOIP clients. LEISURE: Today, many Internet forums have sections devoted to games and funny videos; short cartoons in the form of Flash movies are also popular. Over 6 million people use blogs or message boards as a means of communication and for the sharing of ideas. The pornography and gambling industries have both taken full advantage of the World Wide Web, and often provide a significant source of advertising revenue for other Web sites. Although many governments have attempted to put restrictions on both industries' use of the Internet, this has generally failed to stop their widespread popularity. One main area of leisure on the Internet is multiplayer gaming. This form of leisure creates communities, bringing people of all ages and origins to enjoy the fast-paced world of multiplayer games. These range fromMMORPG to first-person shooters, from roleplaying games to online gambling. This has revolutionized the way many people interact and spend their free time on the Internet.

DBMS & Internet Programming Notes

25

Many use the Internet to access and download music, movies and other works for their enjoyment and relaxation. Many use the World Wide Web to access news, weather and sports reports, to plan and book holidays and to find out more about their random ideas and casual interests. People use chat, messaging and email to make and stay in touch with friends worldwide, sometimes in the same way as some previously had pen pals. Social networking Web sites like Friends Reunited and many others like them also put and keep people in contact for their enjoyment. MARKETING The Internet has also become a large market for companies; some of the biggest companies today have grown by taking advantage of the efficient nature of low-cost advertising and commerce through the Internet; also known as e-commerce. It is the fastest way to spread information to a vast amount of people simultaneously. The Internet has also subsequently revolutionized shopping for example; a person can order a CD online and receive it in the mail within a couple of days, or download it directly in some cases. The Internet has also greatly facilitated personalized marketing which allows a company to market a product to a specific person or a specific group of people more so than any other advertising medium. FUTURE OF THE INTERNET THE MOBILE INTERNET The Internet can now be accessed virtually anywhere by numerous means. Mobile phones, datacards, and cellular routers allow users to connect to the Internet from anywhere there is a cellular network supporting that device's technology. BLOGS One of the things that is so amazing about blogs is their simplicity. A blog is normally a single page of entries. A blog is organized in reverse-chronological order, from most recent entry to least recent. A blog is normally public -- the whole world can see it. The entries in a blog usually come from a single author. A blog is a lot like an online journal or diary. The author can talk about anything and everything. Many blogs are full of interesting links that the author has found. Blogs often contain stories or little snippets of information that are interesting to the author. Even though blogs can be completely freeform, many blogs have a focus. For example, if a blogger is interested in technology, the blogger might go to the Consumer Electronics Show and post entries of the things he/she sees there. In other words, a blog can be anything the author wants it to be. WEB 2.0 (refer video): Online collaboration with sharing data both by the user and by the website creator, Blogs, Vidoes, Photos, RSS Feeds and Online Applications today have created a place where everything is possible.

E-commerce
Introduction Electronic commerce (e-commerce) is a growing aspect of the business community. This formally is the use of digital transactions between and among businesses and individuals. More commonly ecommerce is the use of the Internet to conduct business. Initially emerging from the Electronic Data Interchange (EDI) e-commerce has gone through several major steps to get to its current point. Through these steps there has been an emergence of several subsets of e-commerce and new technologies. As a result of these changes and the growth of electronic commerce benefits and detriments have been brought to society that can be generalized to all the subsets of e-commerce. Looking at economic, privacy and social aspects of society we can see there are issues facing

DBMS & Internet Programming Notes

26

electronic commerce development. It is also possible to see there are some industries that ecommerce has had a greater impact on, such as the culture and information industry. Overall, electronic commerce can be a benefit to society especially if businesses adapt to their customers worries such as privacy concerns. As these problems begin to be solved and technology improves ecommerce will provide individuals with more choice and add further depth to the economy. Concepts Anonymous remailer, B2B exchange, browser, checkout page, common gateway interface, cookie, day trading, denial of service attack, design pattern, disintermediation, distributed objects, dynamic pages, dynamic pricing, e-auction, e-learning, email server, e-mall, e-procurement, e-shop, e-tailing, file transfer protocol, framework, horizontal portal, hyperlink, hypertext mailer, Hypertext Markup Language, information brokerage, Java, online trading, portal, posting, procurement, query, rapid application development, search engine, Secure Sockets Layers, Server Side Includes, Servlet, shopping cart, spam, spider, stateless server, supply chain, third party marketplace, thread, trust brokerage, vertical portal, virtual community. web page, web server, website, webmaster. E-Commerce is the ability of a company to have a dynamic presence on the Internet which allowed the company to conduct its business electronically, in essence having an electronic shop. Products can be advertised, sold and paid for all electronically without the need for it to be processed by a human being. Due to the vastness of the internet advertising and the website can be exposed to hundreds of people around the world for almost nil cost and with information being able to be changed almost instantly the site can always be kept up to date with all the latest products to match with consumers demands. The biggest advantage of E-Commerce is the ability to provide secure shopping transactions via the internet and coupled with almost instant verification and validation of credit card transactions. This has caused E-Commerce sites to explode as they cost much much less than a store front in a town and has the ability to serve many more customers. In the broad meaning electronic commerce (ECommerce) is a means of conducting business using one of many electronic methods, usually involving telephones, computers (or both). E-Commerce is not about the technology itself, it is about doing business using the technology. Electronic commerce, commonly known as e-commerce or eCommerce, consists of the buying and selling of products or services over electronic systems such as the Internet and other computer networks. The amount of trade conducted electronically has grown extraordinarily with wide-spread Internet usage. A wide variety of commerce is conducted in this way, spurring and drawing on innovations in electronic funds transfer, supply chain management, Internet marketing, online transaction processing, electronic data interchange (EDI), inventory management systems, and automated data collection systems. Modern electronic commerce typically uses the World Wide Web at least at some point in the transaction's lifecycle, although it can encompass a wider range of technologies such as e-mail as well. A large percentage of electronic commerce is conducted entirely electronically for virtual items such as access to premium content on a website, but most electronic commerce involves the transportation of physical items in some way. Online retailers are sometimes known as e-tailers and online retail is sometimes known as e-tail. Almost all big retailers have electronic commerce presence on the World Wide Web. Electronic commerce that is conducted between businesses is referred to as business-to-business or B2B. B2B can be open to all interested parties (e.g. commodity exchange) or limited to specific, prequalified participants (private electronic market). Electronic commerce that is conducted between

DBMS & Internet Programming Notes

27

businesses and consumers, on the other hand, is referred to as business-to-consumer or B2C. This is the type of electronic commerce conducted by companies such as Amazon.com. Electronic commerce is generally considered to be the sales aspect of e-business. It also consists of the exchange of data to facilitate the financing and payment aspects of the business transactions. HISTORY There have been several key steps in the history of e-commerce. The first step came from the development of the Electronic Data Interchange (EDI). EDI is a set of standards developed in the 1960s to exchange business information and do electronic transactions. At first there was several different EDI formats that business could use, so companies still might not be able to interact with each other. However, in 1984 the ASC X12 standard became stable and reliable in transferring large amounts of transactions. The next major step occurred in 1992 when the Mosaic web-browser was made available, it was the first point and click browser. The Mosaic browser was quickly ada pted into a downloadable browser, Netscape, which allowed easier access to electronic commerce. The development of DSL was another key moment in the development to of e-commerce. DSL allowed quicker access and a persistent connection to the Internet. Christmas of 1998 was another major step in the development of e-commerce. AOL had sales of 1.2 billion over the 10 week holiday season from online sales. The development of Red Hat Linux was also another major step in electronic commerce growth. Linux gave users another choice in a platform other then Windows that was reliable and open-source. Microsoft faced with this competition needed to invest more in many things including electronic commerce. Napster was an online application used to share music files for free. This application was yet another major step in e-commerce. Many consumers used the site and were dictating what they wanted from the industry. A major merger, in early 2000, between AOL and Time Warner was another major push for electronic commerce. The merger, worth $350 million, brought together a major online company with a traditional company. In February 2000 hackers attacked some major players of e-commerce, including Yahoo, e-bay and Amazon. In light of these attacks the need for improved security came to the forefront in the development of electronic commerce. It is predicted that that revenues, up until 2006, will grow 40% to 50% yearly. Expectations of higher prices as well as larger profits for e-commerce business are also present. Also, we will see a larger presence by experienced traditional companies, such as Wal-Mart, on the Internet. It is believed companies in general will take this mixed strategy of having stores online and offline in order to be successful. It can be seen that there will be a large growth in Business-to-Consumer (B2C) ecommerce, which is online businesses selling to individuals. However, even though B2C electronic commerce may be the most recognizable there are different varieties. Today the largest electronic commerce is Business-to-Business (B2B). Businesses involved in B2B sell their goods to other businesses. In 2001, this form of e-commerce had around $700 billion in transactions. Other varieties growing today include Consumer-to-Consumer (C2C) where consumers sell to each other, for example through auction sites. Peer-to-Peer (P2P) is another form of ecommerce that allows users to share resources and files directly Types of E-Commerce E-commerce is the use of Internet and the web to transact business but when we focus on digitally enabled commercial transactions between and among organizations and individuals involving information systems under the control of the firm it takes the form of e-business. Nowadays, 'e' is

DBMS & Internet Programming Notes

28

gaining momentum and most of the things if not everything is getting digitally enabled. Thus, it becomes very important to clearly draw the line between different types of commerce or business integrated with the 'e' factor. There are mainly five types of e-commerce models: 1. Business to Consumer (B2C) - As the name suggests, it is the model involving businesses and consumers. This is the most common e-commerce segment. In this model, online businesses sell to individual consumers. When B2C started, it had a small share in the market but after 1995 its growth was exponential. The basic concept behind this type is that the online retailers and marketers can sell their products to the online consumer by using crystal clear data which is made available via various online marketing tools. E.g. An online pharmacy giving free medical consultation and selling medicines to patients is following B2C model. 2. Business to Business (B2B) - It is the largest form of e-commerce involving business of trillions of dollars. In this form, the buyers and sellers are both business entities and do not involve an individual consumer. It is like the manufacturer supplying goods to the retailer or wholesaler. E.g. Dell sells computers and other related accessories online but it is does not manufacture all those products. So, in order to sell those products, it first purchases them from different businesses i.e. the manufacturers of those products. 3. Consumer to Consumer (C2C) - It facilitates the online transaction of goods or services between two people. Though there is no visible intermediary involved but the parties cannot carry out the transactions without the platform which is provided by the online market maker such as eBay. 4. Peer to Peer (P2P) - Though it is an e-commerce model but it is more than that. It is a technology in itself which helps people to directly share computer files and computer resources without having to go through a central web server. To use this, both sides need to install the required software so that they can communicate on the common platform. This type of e-commerce has quite low revenue generation as from the beginning it has been inclined to the free usage due to which it sometimes got entangled in cyber laws. 5. M-Commerce - It refers to the use of mobile devices for conducting the transactions. The mobile device holders can contact each other and can conduct the business. Even the web design and development companies optimize the websites to be viewed correctly on mobile devices. There are other types of e-commerce business models too like Business to Employee (B2E), Government to Business (G2B) and Government to Citizen (G2C) but in essence they are similar to the above mentioned types. Moreover, it is not necessary that these models are dedicatedly followed in all the online business types. It may be the case that a business is using all the models or only one of them or some of them as per its needs.

DBMS & Internet Programming Notes

29

HTML Introduction: HTML stands for Hypertext Markup Language. It is used to display the document in the web browsers. HTML pages can be developed to be simple text or to be complex multimedia program containing sound, moving images and java applets. HTML is considered to be the global publishing format for Internet. It is not a programming language. HTML was developed by Tim Berners-Lee. HTML standards are created by a group of interested organizations called W3C (world wide web consortium). In HTML formatting is specified by using tags. A tag is a format name surrounded by angle brackets. End tags which switch a format off also contain a forward slash. Points to be remembered for HTML tags: Tags are delimited by angled brackets. They are not case sensitive i.e., <head>, <HEAD> and <Head> is equivalent. If a browser not understand a tag it will usually ignore it. Some characters have to be replaced in the text by escape sequences. White spaces, tabs and newlines are ignored by the browser.

Structure of an HTML document: All HTML documents follow the same basic structure. They have the root tag as <html>, which contains <head> tag and <body> tag. The head tag is used for control information by the browser and the body tag contains the actual user information that is to be displayed on the screen. The basic document is shown below. <html> <head> <title> Basic HTML document </title> </head> <body> <h1> Welcome to the world of Web Technologies</h1> <p> A sample HTML program written by Amer </p> </body> </html> Besides head and body tag, there are some other tags like title, which is a sub tag of head, that displays the information in the title bar of the browser. <h1> is used to display the line in its own format i.e., bold with some big font size. <p> is used to write the content in the form of paragraph. Comments in HTML documents start with <! and end with >. Each comment can contain as many lines of text as you like. If comment is having more lines, then each line must start and end with -- and must not contain -- within its body. <! -- this is a comment line - -- which can have more lines - ->

Basic HTML tags 1. Body tag : Body tag contain some attributes such as bgcolor, background etc. bgcolor is used for background color, which takes background color name or hexadecimal number and #FFFFFF and background attribute will take the path of the image which you can place as the background image in the browser. <body bgcolor=#F2F3F4 background= c:\amer\imag1.gif>

DBMS & Internet Programming Notes

30

2. Paragraph tag: Most text is part of a paragraph of information. Each paragraph is aligned to the left, right or center of the page by using an attribute called as align. <p align=left | right | center> 3. Heading tag: HTML is having six levels of heading that are commonly used. The largest heading tag is <h1> . The different levels of heading tag besides <h1> are <h2>, <h3>, <h4>, <h5> and <h6>. These heading tags also contain attribute called as align. <h1 align=left | right | center> . . . . <h2> 4. hr tag: This tag places a horizontal line across the system. These lines are used to break the page. This tag also contains attribute i.e., width which draws the horizontal line with the screen size of the browser. This tag does not require an end tag. <hr width=50%>. 5. base font: This specify format for the basic text but not the headings. <basefont size=10> 6. font tag: This sets font size, color and relative values for a particular text. <font size=10 color=#f1f2f3> 7. bold tag: This tag is used for implement bold effect on the text <b> . </b> 8. Italic tag: This implements italic effects on the text. <i>.</i> 9. strong tag: This tag is used to always emphasized the text <strong>.</strong> 10. tt tag: This tag is used to give typewriting effect on the text <tt>..</tt> 11. sub and sup tag: These tags are used for subscript and superscript effects on the text. <sub> .</sub> <sup>..</sup> 12. Break tag: This tag is used to the break the line and start from the next line. <br> 13. &amp &lt &gt &nbsp &quot

DBMS & Internet Programming Notes

31

These are character escape sequence which are required if you want to display characters that HTML uses as control sequences. Example: < can be represented as &lt. 14. Anchor tag: This tag is used to link two HTML pages, this is represented by <a> <a href= path of the file> some text </a> href is an attribute which is used for giving the path of a file which you want to link. Example 1: HTML code to implement common tags.

mypage.html <html> <head> <! -- This page implements common html tags --> <title> My Home page </title> </head> <body > <h1 align="center"> GREEN FORT ENGINEERING COLLEGE</h1> <h2 align="center"> Bandlaguda, Hyderabad</h2> <basefont size=4> <p> This college runs under the <tt>management</tt> of <font size=5> <b><i>&quot Syed Hashim Education Society&quot &amp it is</i></b></font><br> affiliated to <strong> JNTU</strong> <hr size=5 width=80%> <h3> <u>&ltSome common tags&gt</u> </h3><br> <a href="F:\feroz\wtlab\prog1\list.html"> List </a><br> <a href="F:\feroz\wtlab\prog1\table.html"> Table </a><br> </body> </html> Lists: One of the most effective ways of structuring a web site is to use lists. Lists provides straight forward index in the web site. HTML provides three types of list i.e., bulleted list, numbered list and a definition list. Lists can be easily embedded easily in another list to provide a complex but readable structures. The different tags used in lists are explained below. <li> ..</li> The ordered(numbered) and unordered(bulleted) lists are each made up of sets of list items. This tag is used to write list items <ul type=disc | square | circle > ..</ul> This tag is used for basic unordered list which uses a bullet in front of each tag, every thing between the tag is encapsulated within <li> tags. <ol type=1 | a | I start=n>..</ol> This tag is used for unordered list which uses a number in front of each list item or it uses any element which is mentioned in the type attribute of the <ol> tag, start attribute is used for indicating the starting number of the list. <dl>.. </dl> This tag is used for the third category i.e., definition list, where numbers or bullet is not used in front of the list item, instead it uses definition for the items.

DBMS & Internet Programming Notes

32

<dt>..</dt> This is a sub tag of the <dl> tag called as definition term, which is used for marking the items whose definition is provided in the next data definition. <dd> .</dd> This is a sub tag of the <dd> tag, definition of the terms are enclosed within these tags. The definition may include any text or block. Example 2: HTML code showing list tags. <html> <head> <title> list page </title> </head> <body> <h3> Course details </h3><br> <ul type="disc"> <li> Computer Science and Engineering </li> <li> Information Technology</li> <li> Electronics and Communication </li> </ul><br> <ol type="I" start=4> <li> Mechanical Engineering</li> <li> Electronics and Electrical Engineering</li> </ol><br> <h3> Subject Details </h3><br> <dl> <dt> Web Technologies</dt> <dd> This subject is related to the technologies used in web applications</dd> </dl> <a href="d:\feroz\gfec\wtlab\asgm1.html">back</a> </body> </html> Tables: Table is one of the most useful HTML constructs. Tables are find all over the web application. The main use of table is that they are used to structure the pieces of information and to structure the whole web page. Below are some of the tags used in table. <table align=center | left | right border=n width=n% cellpadding=n cellspacing=n></table> Every thing that we write between these two tags will be within a table. The attributes of the table will control in formatting of the table. Cell padding determines how much space there is between the contents of a cell and its border, cell spacing sets the amount of white space between cells. Width attribute sets the amount of screen that table will use. <tr> .. </tr> This is the sub tag of <table> tag, each row of the table has to be delimited by these tags. <th></th> This is again a sub tag of the <tr> tag. This tag is used to show the table heading .

DBMS & Internet Programming Notes

33

<td>..</td> This tag is used to give the content of the table. Example 3: HTML code showing the use of table tag <html> <head> <title> table page</title> </head> <body> <table align="center" cellpadding="2" cellspacing="2" border="2"> <caption>Time for III year IT</caption> <tr><th> I period </th> <th> II peiord> </th> </tr> <tr> <td> wt </td> <td> uml</td> </tr> </table> </body> </html> Color and Image: Color can be used for background, elements and links. To change the color of links or of the page background hexadecimal values are placed in the <body> tag. <body bgcolor = #nnnnnn text = #nnnnnn link= #nnnnnn vlink= #nnnnnn alink = #nnnnnn> The vlink attribute sets the color of links visited recently, alink the color of a currently active link. The six figure hexadecimal values must be enclosed in double quotes and preceded by a hash(#). Images are one of the aspect of web pages. Loading of images is a slow process, and if too many images are used, then download time becomes intolerable. Browsers display a limited range of image types. <body background = URL> This tag will set a background image present in the URL. Another tag that displays the image in the web page, which appears in the body of the text rather than on the whole page is given below <img src=URL height=n width=n align = top | center | bottom >

Example 4: HTML code that implements color and image <html> <head> <! -- This page implements color and image --> <title> My Home page </title> </head> <body bgcolor="gray" text="magneta" vlink="yellow" alink="brown"> <img src= d:\feroz\gfec\wtlab\asgm1.gif>

DBMS & Internet Programming Notes

34

</body> </html>

Example 5: HTML code that implements background image <html> <head> <! -- This page implements background image --> <title> My Home page </title> </head> <body background=d:\feroz\gfec\wtlab\asgm1.gif "> </body> </html> Frames: Frames provide a pleasing interface which makes your web site easy to navigate. When we talk about frames actually we are referring to frameset, which is a special type of web page. The frameset contains a set of references to HTML files, each of which is displayed inside a separate frame. There are two tags related to frames i.e., frameset and frame <frameset cols= % , % | rows= % , %>..</frameset> <frame name=name src=filename scrolling = yes | no frameborder =0|1> Forms: Forms are the best way of adding interactivity of element in a web page. They are usually used to let the user to send information back to the server but can also be used to simplify navigation on complex web sites. The tags that use to implement forms are as follows. <forms action=URL method = post | get>.</form> When get is used, the data is included as part of the URL. The post method encodes the data within the body of the message. Post can be used to send large amount of data, and it is more secure than get. The tags used inside the form tag are: <input type = text | password | checkbox | radio | submit size=n> name=string value=string

In the above tag, the attribute type is used to implement text, password, checkbox, radio and submit button. Text: It is used to input the characters of the size n and if the value is given than it is used as a default value. It uses single line of text. Each component can be given a separate name using the name attribute. Password: It works exactly as text, but the content is not displayed to the screen, instead an * is used. Radio: This creates a radio button. They are always grouped together with a same name but different values. Checkbox: It provides a simple checkbox, where all the values can be selected unlike radio button. Submit: This creates a button which displays the value attribute as its text. It is used to send the data to the server.

DBMS & Internet Programming Notes

35

<select name=string>..</select> This tag helps to have a list of item from which a user can choose. The name of the particular select tag and the name of the chosen option are returned. <option value=string selected></option> The select statement will have several options from which the user can choose. The values will be displayed as the user moves through the list and the chosen one returned to the server. <textarea name=string rows=n cols=n>.</textarea> This creates a free format of plain text into which the user can enter anything they like. The area will be sized at rows by cols but supports automatic scrolling. Example 6: HTML code that implements forms <html> <head> <title>form</title> </head> <body> <p align="left">Name :<input type="text" maxlength=30 size=15> <p align="left">Password:<input type="password" maxlenght=10 size=15> <p align="left">Qualification: <br><input type="checkbox" name="q" value="be">B.E <input type="checkbox" name="q" value="me">M.E <p align="left">Gender:<br> <input type="radio" name="g" value="m">Male <input type="radio" name="g" value="f">Female <p align="left">course:<select name="course" size=1> <option value=cse selected>CSE <option value=it>CSIT </select> <p align="left">Address:<br><textarea name="addr" rows=4 cols=5 scrolling=yes></textarea> <p align="center"><input type="submit" name="s" value="Accept"> <p align="center"><input type="reset" name="c" value="Ignore"> </body> </html> Example 7: HTML code that implements frames <html> <head> <title> My page </title> </head> <frameset rows="25%,50%"> <frame name="a" src="f:\feroz\wtlab\asgm1.html"> <frameset cols="25%,50%"> <frame name="b" src="f:\feroz\wtlab\index.html"> <frame name="abc" src="f:\feroz\wtlab\welcome.html"> </frameset> </frameset> </html>

Das könnte Ihnen auch gefallen