Page 146 - Informatics_Practices_Fliipbook_Class12
P. 146

4. UNIQUE Constraint

        UNIQUE constraint when applied on any attribute, will ensure that no two tuples in the relation should have the same
        attribute value. For example, you may enforce each department to have a unique manager by applying UNIQUE constraint
        on attribute Mgr_Id of relation DEPARTMENT. This would imply that two departments cannot have the same manager.


               Uniqueness constraint: Applies to an attribute.
               No two rows can have same value of the specified attribute.

        5. Domain Constraint

        Domain Constraint allows you to specify a set of values that a particular attribute may take. For example, attribute
        Gender has a domain constraint ensuring that it may take only two values, either M or F. Similarly, we may constraint
        attribute Salary to take values within a reasonable range of numbers, say, between 8000 and 100000.

        4.3 Structured Query Language (SQL)

        Structured Query Language (SQL) is used to create and manipulate relational databases. It is a high-level interactive
        language that allows users to specify what is required to be done in the form of queries. Unlike other high-level
        languages, we do not need to specify how the SQL operations are implemented. Thus, SQL becomes an easy to learn
        database language, so it is widely used. It efficiently manages large databases, provides fast responses to the queries
        operating on data and facilitates an authentication mechanism that ensures the security of data.


               SQL: Most popular language for creating and manipulating relational databases.


        Based on their functionality, SQL operations are organised in two categories, DDL (Data Definition Language) and DML
        (Data Manipulation Language), as described below:

        Data Definition Language (DDL)
        Data Definition Language (DDL) is used for describing database structure.  It is used to  create and delete databases and
        tables. The attributes of already existing tables can also be added, deleted or modified using DDL statements or DDL
        commands. Some of the examples of DDL statements  are CREATE TABLE, ALTER TABLE, DROP TABLE, and
        TRUNCATE. In this chapter, we will discuss these in detail.



               DDL: Used for defining database attributes, their types, and constraints on attribute values.


        Data Manipulation Language (DML)

        DML is used to retrieve and modify data. It includes statements that enable us to store and retrieve information
        from database tables and modify the already stored data in the database. SQL statements such as INSERT, SELECT,
        DELETE, and UPDATE are used for this purpose.



               DML: Used to retrieve and modify data.





               The results produced by an SQL statement may be saved in the form of views that can be used later.



          132  Touchpad Informatics Practices-XII
   141   142   143   144   145   146   147   148   149   150   151