This presentation will cover:

A Brief History of DBMS

 View

in database  MySQL installation

The first to market was Relational Software's product named Oracle The second was Relational Technology's Ingres. Oracle and DB2 in nth generation forms while the Ingres technology was bought by Computer Associates. IBM then released improved products in 1982 named SQL/DS and DB2.   .SQL – DBMS History  DBMS History  The IBM‟s System/R was not the first DBMS.

SQL .Standards   SQL is a open language without corporate ownership.  . The ANSI-SQL (American National Standards Institute) group has published three standards over the years: SQL89 (SQL1) SQL92 (SQL2) SQL99 (SQL3)  The majority of the language has not changed through these updates. The SQL standard from ANSI is considered the "pure" SQL and called ANSI-SQL.

the method of implementation is not uniform. So most products offers extra features. these additions are generally not compatible with competitor's SQL products. most DBMS sold today have an automatic way to assign a serial number feature since serial numbering is so common. However. It is always safest to stick with pure SQL The enhancements are not all bad because these extensions are very useful.SQL – Enhanced features  Every DBMS vendor wants their products to be different. .    For example.

we can modify a view and present the data as if the data were coming from a single table. The fields in a view are fields from one or more real tables in the database. just like a real table. In some cases. a VIEW is a virtual relation based on the result-set of a SELECT statement. A view contains rows and columns.What is a View?   In SQL. Syntax: CREATE VIEW view_name AS SELECT column_name(s) FROM table_name WHERE condition  .

Tables & Views  When we say Relation. Temporary results .SQL – Relations. it could be a Table or a View. Stored relations tables We sometimes use the term “base relation” or “base table” 2. Virtual relations views 3. There are three kind of relations: 1.

SQL – Create View  Example: Create a view with title and year and made by Paramount studio. year. inColor. .year FROM Movie WHERE studioName = „Paramount‟. studioName. length. Movie (title. producerC#) CREATE VIEW ParamountMovie AS SELECT title.

 . etc. joins. By adding functions. Have same result as Table SELECT title FROM Movie WHERE studioName = „Paramount‟ AND year = „1979‟. a stored procedure.. View SELECT title FROM ParamountMovie WHERE year = „1979‟. it allows us to present exactly the data we want to the user.SQL – Querying View  A view could be used from inside a query. or from inside another view. to a view.

.SQL . StarsIn Table WHERE title = movieTitle AND year = movieYear.Querying View con‟t  Query involving both view and table SELECT DISTINCT starName View FROM ParamountMovie.

. cert#. netWorth) CREATE VIEW MovieProd AS SELECT title. MovieExec WHERE producerC# = cert#. studioName. SELECT name FROM MovieProd WHERE title = „Gone With the Wind‟. inColor. year. name FROM Movie. address. MovieExec WHERE producerC# = cert# AND title = „The War Of the World‟. producerC#) MovieExec (name.Querying View example Movie (title. length.SQL .  Same result as query from tables SELECT name FROM Movie.

we might want to distinguish attributes by giving the different name. name FROM Movie. .Renaming Attributes in View  Sometime.SQL . prodName) AS SELECT title. MovieExec WHERE producerC# = cert#. CREATE VIEW MovieProd (movieTitle.

we actually modify a table through a view. Here are rules have been defined in SQL for updateable views:  selecting (SELECT not SELECT DISTINCT) some attributes from one relation R (which may itself be an updateable view)  The WHERE clause must not involve R in a subquery.Modifying View When we modify a view.  . Many views are not updateable. The list in the SELECT clause must include enough attributes that will allow us to insert tuples into the view as well as table. All other attributes will be filled out with NULL or the proper default values.SQL .

1979). „Star Trek‟. we need to add attribute studioName to it‟s SELECT clause because it makes more sense if the studioName is Paramount instead of NULL. Then INSERT INTO ParamountMovie VALUES („Paramount‟. To make the view ParamountMovie updateable. year FROM Movie WHERE studioName = „Paramount‟. CREATE VIEW ParamountMovie AS SELECT studioName. Title year length „Star Trek‟ 1979 0 inColor NULL studioName „Paramount‟ producerC# NULL . title. 1979).SQL – Modifying View (INSERT) INSERT INTO ParamountMovie VALUES („Star Trek‟.

DELETE FROM ParamountMovie WHERE title LIKE „%Trek%‟.SQL . It is turned into the base table delete DELETE FROM Movie WHERE title LIKE „%Trek%‟ AND studioName = „Paramount‟.Modifying View (DELETE)  Suppose we wish to delete all movies with “Trek” in their title from the updateable view ParamountMovie. .

SQL . .Modifying View (UPDATE)  UPDATE from an updateable view UPDATE ParamountMovie SET year = 1979 WHERE title = „Star Trek the Movie‟. It is turned into the base table update UPDATE Movie SET year = 1979 WHERE title = „Star Trek the Movie‟ AND studioName = „Paramount‟.

SQL – View (DROP)  DROP view: All views can be dropped. DROP VIEW ParamountMovie. However. DROP TABLE Movie . DROP TABLE will delete the table and also make the view ParamountMovie unusable. whether or not the view is updateable.   DROP VIEW does not affect any tuples of the underlying relation (table) Movie.

Sign up to vote on this title
UsefulNot useful