Creating a view-data control, Database Management System

Assignment Help:

Creating a view:

  • A query can be embedded within the CREATE VIEW STATEMENT
  • A query can have complex select statements containing join, groups and sub- queries
  • A query that describes the view cannot contain an order by clause.
  • DML operation (delete/ add / modify) cannot be applied if the view have any of the following:

 

Delete (You can't delete if view contains following)

Modify (you cannot modify if view contains following)

Insert (you cannot insert if view contains following)

  • Group functions
  • A group by clause
  • A distinct keyword
  • Group functions
  • A group by clause
  • A distinct keyword
  • Columns defined by

Expressions

  • Group functions
  • A group by clause
  • A distinct keyword
  • Columns defined by

Expressions

  • There are Not Null Columns in the base tables that are not selected by view.

Example:  Create a view named employee salary having minimum, maximum and average salary for every department.

CREATE VIEW EMPSAL (NAME, MINSAL, MAXSAL, AVGSAL) AS

SELECT D.DNAME, MIN(E.SAL),MAX(E.SAL),AVG(E.SAL)

 FROM EMP E, DEPT D

WHERE E.DEPTNO=D.DEPTNO GROUP BY D.DNAME;

To view the result of the command above you can give the following command:

SELECT * FROM EMPSAL;

You may get some sample output like:

NAME   MINSAL          MAXSA                 AVG                    SAL

--------------         ---------                ---------         -------------

ACCOUNTING            1300                      5000           2916.6667

RESEARCH                 800                      3000               2175

SALES                      950                      2850           1566.6667

To view the structure of the view so created, the command is given below:

DESCRIBE EMPSAL;

Name                                                 Null?                   Type

---------------                                   ------------   ---------------------

NAME                                                VARCHAR2           (14)

MINSAL                                               NUMBER

MAXSAL                                              NUMBER

AVGSAL                                              NUMBER

 


Related Discussions:- Creating a view-data control

Fds in relationships and teaches relationship, FDs in Relationships:  E...

FDs in Relationships:  Enrols Relationship: None as it is many to many Teaches Relationship : Course code → Instructor Instructor → Course code The next question is:

Two phase locking technique, growing phase and shrinking phase are disjoint...

growing phase and shrinking phase are disjoint, why ?

What is de-normalization, What is De-normalization? De-normalization is...

What is De-normalization? De-normalization is the method of attempting to optimize the performance of a database by adding redundant data. It is sometimes essential because cur

DBMS, what is specialization?

what is specialization?

Selective replication-data replication, Selective replication: This is a c...

Selective replication: This is a combination of generating small fragments of relation and replicating them rather than a entire relation. The data should be fragmented on require

Cartisian product, Explain the cartesian product in Database Management Sys...

Explain the cartesian product in Database Management System

What are the disadvantages of file-processing system, What are the disadvan...

What are the disadvantages of file-processing system?  Ans: The Disadvantages of File-Processing System a. Data redundancy and inconsistency - Data redundancy means not nece

In an e-r diagram how attributes are represented, In an E-R diagram how att...

In an E-R diagram how attributes are represented ? In an E-R diagram attributes are represented in a ellipse.

List two restrictions that are applied on the modification, List two restri...

List two restrictions that are applied on the modification (updation, insertion or deletion) of base tables through view.  Ans: The two restrictions are: 1. If a view

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd