SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Downloaden Sie, um offline zu lesen
CHAPTER : STRUCTURED QUERY LANGUAGE


Chapter Objectives
       At the end of this chapter, you should be able to:
        understand the general concepts of the relational model;

        explain the common integrity rules.


Essential Reading
       An introduction to Database System Volume I (5th Edition), C.J.Date (1990), Addison
       Wesley. [Chapter 11 - 12]
       Modem Database Management (4th Edition), Fred McFadden & Jeffrey A. Hoffer (1994),
       Benjamin/Cummings. [Chapter 8, page 283-316]




Useful Websites to learn Database and Programming:

http://erwinglobio.wix.com/ittraining
http://ittrainingsolutions.webs.com/
http://erwinglobio.sulit.com.ph/
http://erwinglobio.multiply.com/




Prof. Erwin M. Globio, MSIT                                                      7-1
DB212   CHAPTER 7: STRUCTURED QUERY LANGUAGE




7-2                     Prof. Erwin M. Globio, MSIT
DB212                                      CHAPTER 7: STRUCTURED QUERY LANGUAGE



7.1       Relational Data Structures and Concepts
          Two-dimensional tables whose attributes values are atomic. This is to say that at every
          row-and-column position within the table, there always exists precisely one value, never a list
          of values. (Recalls: Relations do not contain repeating groups after INF.)
          There are no duplicate rows. (Recall: There is always a primary key in a relation.)
          Rows (tuples) are unordered.

            S#               SNAME                        STATUS                        CITY
            S1               Smith                        21                            London
            S2               Jones                        10                            Paris
            S3               Mary                         30                            Paris
            S4               Clark                        20                            Athens
          <----------------------------------- Degree ------------------------------------->
          Degree of a relation is the number of attributes in a relation.
          Cardinality of a relation is the number of tuples in a relation.
          Domain is a pool of values, from which one of more attributes draw their actual values. For
          example, a domain of supplier numbers is the set of all possible supplier numbers and the
          domain.

7.2       Integrity Rules
              The entity integrity rules No component of the primary key of a relation is allowed to
          accept nulls. Bu "null", we mean that information is missing for some reason. Suppose in the
          supplier relation, there is a tuple for which the supplier-no is null. This would be like saying
          that there was a supplier in the real world that had no identity. This is absurd.
             The referential integrity rule The database must not contain any unmatched foreign key
          values. By the term "unmatched foreign key value", we mean a non-null foreign key value for
          which there does not exist a matching value of the primary key in the relevant target relation.
             The referential integrity rule says that if B references A, then A must exist.
          Note:   Foreign key and referential integrity concepts are defined in terms of one
                  another. Thus, "support for referential integrity" and "support for foreign keys" mean
                  exactly the same thing.)
              The basic idea is as follows:
              For each foreign key, there are three questions that need to be answered:
                  Can that foreign key accept nulls? For example, does it make sense for a shipment to
                   exist for which the supplier is unknown?




Prof. Erwin M. Globio, MSIT                                                                      7-3
DB212                                  CHAPTER 7: STRUCTURED QUERY LANGUAGE


               What should happen on an attempt to delete the target of a foreign key references?
                For example, an attempt to delete a supplier for which there exists at least at one
                matching shipment? Let us consider more definitely the following cases:
                Restricted        The delete operation is "restricted" to the case where there are
                                  no such matching shipments (it is rejected otherwise)
                 Cascades         The delete operation "cascades" to delete those matching
                                  shipments also
                 Nullifies        The foreign key is set to null in all such matching shipments
                                  and the supplier is then deleted (of course, this case could not
                                  apply if the foreign key cannot accept nulls in the first place)

               What should happen on an attempt to update the primary key of a foreign key
                reference? For example, an attempt to update the supplier number for a supplier for
                which there exists at least one matching shipment? Let us consider the following
                cases:
                Restricted        The update operation is "restricted" to the case where there are
                                  no such matching shipments (it is rejected otherwise)
                 Cascades         The update operation "cascades" to updates the foreign key in
                                  those matching shipments also
                 Nullifies        The foreign key is set to null in all such matching shipments
                                  and the supplier is then updated (of course, this case could not
                                  apply if the foreign cannot accept nulls in the first place)

        Note:   Restricted-Cascaded-Nullifies options for the foreign key delete and update rules do
                not exhaust the possibilities. They are just common practices.

7.3     SQL and Relational Model
        SQL (Structured Query Language) is a relational language, which provides an interface
        between the user and the RDBMS

        7.3.1 A Brief Decomposition
        SQL's capabilities are divided between the data description language (DDL) and the data
        manipulation language (DML).

            DDL
            Create tables                               Query table data
            Modify tables (ALTER)                       Modify table data
            Create indexes                              -          Insert
            Drop tables                                 -          Delete
            Drop indexes                                -          Update
            Authorization (GRANT)                       Aggregate functions
            Deauthorisation (REVOKE)




7-4                                                               Prof. Erwin M. Globio, MSIT
DB212                                 CHAPTER 7: STRUCTURED QUERY LANGUAGE


        The purpose of the DDL is to create entries in the catalogue (sometimes called the data
        dictionary or, in some large systems, the repository). The catalogue is managed by the
        RDBMS and it is a requirement of the Relational Model that the catalogue itself takes the
        form of normalized tables. The update of these tables is quite transparent to the user.

7.4     Relational Data Definition Insql (DDL)

         Data Types
         DECIMAL (m,n)                         Signed numbers, where m is the total number of
                                               digits to the right of the decimal point.
         INTEGER                               Large (up to 11 digits) positive or negative
                                               whole numbers
         SMALL                                 Small (5 or 6 digits, depending on the DBMS)
                                               positive or negative whole numbers. By
                                               specifying this data type, less storage space
                                               is required
         FLOAT (m,n)                           Whole and fractional numbers represented in
                                               scientific notation, where m is the total number
                                               of digits (including sign), and n is the number
                                               of digits to the right of the decimal point.
         CHAR (n)                              Alphanumeric (character) data, where n is the
                                               maximum length for the character string; n
                                               character positions are allocated to each
                                               instance of a CHAR column.
         DATE                                  Calendar dates. A system variable can be used
                                               to set the format for the date data type.
         LOGICAL                               True or false values

         DDL Commands                          Description
         CREATE TABLE                          Define the structure of a new table
         INSERT                                Places a new row in a table based on values
                                               supplied in the statement, copies one or more
                                               rows derived from other database into a table,
                                               extracts data from one table and inserts them
                                               into another.
         UPDATE                                Changes values in one or more specified rows
                                               of a table by replacing current values with
                                               constant or the results of calculation.
         DELETE                                Removes one of more rows from a table.
         CREATE VIEW                           Names the view and optionally specifies
                                               column names to be used in place of those of
                                               the base table.
         CREATE INDEX                          Defines an index on one column that enables
                                               rapid access to the rows of a table in a sequence
                                               or randomly by the key value.
         ALTER TABLE                           Adds columns to an existing.
         DROP TABLE                            Deletes table.
         DROP INDEXES                          Deletes index.
         GRANT                                 Granting user access.
         REVOKE                                Removing privileges given to a user.
         (DBA privileges)




Prof. Erwin M. Globio, MSIT                                                                7-5
DB212                                     CHAPTER 7: STRUCTURED QUERY LANGUAGE


        Illustrations: The following is the suppliers-parts-projects database

        SUPPLIER                                                          PROJECTS

         S#        SNAME          STATUS        CITY                 J#     JNAME         CITY
         S1        SMITH          20            LONDON               J1     SORTER        PARIS
         S2        JONES          10            PARIS                J2     PUNCH         ROME
         S3        BLAKE          30            PARIS                J3     READER        ATHENS
         S4        CLARK          20            LONDON               J4     CONSOLE       ATHENS
         S5        ADAMS          30            ATHENS               J5     COLLATOR      LONDON
                                                                     J6     TERMINAL      OSLO
                                                                     J7     TAPE          LONDON

          PART
         P#            PNAME              COLOR           WEIGHT           CITY
         P1            NUT                RED             12               LONDON
         P2            BOLT               GREEN           17               PARIS
         P3            SCREW              BLUE            17               ROME
         P4            SCREW              RED             14               LONDON
         P5            CAM                BLUE            14               PARIS
         P6            COQ                RED             19               LONDON




         S#          P#              J#             QTY                    S#        P#    QTY
         S1          P1              J1             200                    S1        P1    300
         S1          P1              J4             700                    S1        P2    200
         S2          P3              J1             400                    S1        P3    400
         S2          P3              J2             200                    S1        P4    200
         S2          P3              J3             200                    S1        P5    100
         S2          P3              J4             500                    S1        P6    100
         S2          P3              J5             600                    S2        P1    300
         S2          P3              J6             400                    S2        P2    400
         S2          P3              J7             800                    S3        P2    200
         S2          P5              J2             100                    S4        P2    200
         S3          P3              J1             200                    S4        P4    300
         S3          P4              J2             500                    S4        P5    400
         S4          P6              J3             300
         S5          P6              J7             300
         S5          P6              J2             200
         S5          P1              J4             100
         S5          P3              J4             200
         S5          P4              J4             800
         S5          P5              J4             400
         S5          P6              J4             500




7-6                                                                 Prof. Erwin M. Globio, MSIT
DB212                                   CHAPTER 7: STRUCTURED QUERY LANGUAGE


        Example:
          Adding data to a table
               Adding of one new row to a table
                INSERT INTO SUPPLIE
                            VALUES ( "S6", "MARY" , 30, "NEW YORK" ) ;

               Transferring rows from external file to a database table
                INSERT INTO SUPPLIER
                SELECT *
                FROM NEW-SUPPLIER
                WHERE STATUS >20 ;

           Deleting database contents
            Rows can be deleted individually or in groups.
               Deleting a row from a table
                DELETE FROM PART
                            WHERE WEIGHT = 12 ;

               Deleting all rows of a table DELETE FROM PART ;
        Note:   Deletion must be done with care when rows from several relations are involved.
                For example, if we deleted a SUPPLIER row or a PROJECT row, or a PART
                row, we will have a referential integrity violation in the SPJ or SP tables.)

           Changing database contents
            To update data in SQL, we must inform the DBMS what relation, columns and rows are
            involved.
                UPDATE SUPPLIER
                     SET CITY = ROME
                     WHERE SUPPLIER-NO = "S3" ;

           Constructing a View for more than one table
            A view is also called a virtual table because it does not actually contain stored data,
            combines data that is selected from one or more base tables of the other views. If the data
            in the base tables changes, so does the information displayed using the view.
            We can use a view to let someone access just the rows and columns that the person needs
            from base tables. We can omit columns containing irrelevant or sensitive information.
            For instance,
                CREATE VIEW SUPPLIER-PART
                      (SUPPLIER-NO, PART-NO,QUANTITY)
                      AS SELECT S#, P#, QTY
                      FROM SP
                      WHERE QTY > = 200;




Prof. Erwin M. Globio, MSIT                                                                   7-7
DB212                                    CHAPTER 7: STRUCTURED QUERY LANGUAGE


        This will create an external presentation to the user on the table SP.
                 CREATE VIEW DEALS
                           (SUPPLIER-NAME, CITY, PROJRCT)
                           AS SELECT SNAME, SUPPLIER. CITY, JNAME
                           FROM SUPPLIER, PROJECT
                           WHERE SUPPLIER, CITY = PROJECT. CITY;
        This view links suppliers with the project. The two tables are related using their common
        CITY column.

           Creating indexes
            You can create indexes in most RDBMSs to provide rapid random and sequential access
            to base-table data.
            For example, to create an index on the supplier table for the S#:
                CREATE INDEX S-NO
                      ON SUPPLIER (S#);

           Changing table definitions
            We may change table definitions in many SQL RDBMSs by ALTERING column
            specifications.
            For example, to add a new column ADDRESS in the SUPPLIER table:
                         ALTER TABLE SUPPLIER
                               ADD (ADDRESS CHAR (30) ) ;

           Deleting tables
            Once a table is deleted, all the data will be deleted permanently and you cannot get it
            back.
                         DROP VIEW tablename;

           Deleting views
            Here, the TABLES(s) on which the VIEW is based will not be changed.
                DROP INDEX indexname;




7-8                                                                Prof. Erwin M. Globio, MSIT
DB212                                    CHAPTER 7: STRUCTURED QUERY LANGUAGE



7.5     Basic SQL Construct (DML)
        SQL's DML is divided into two parts, retrieval commands and updates commands. The
        following are the eight operators used by the RM (Relational Model) for retrieval of data from
        normalized relations:
                        Restrict            Project
                                                                     a        X       a        x
                                                                     b        y       b        y
                                                                     c                c        x
                                                                                      a        y
                                                                                      b        x
                                                                                      c        y



                        Union                Intersection                Difference




        These represent the eight original operators used by the relational model for retrieval model
        for retrieval of data from normalization relations. Product, union, insertion and difference are
        operators in a branch of mathematics called set theory. Restrict, project, join and divide are
        operators in a branch of mathematics called relational theory.




Prof. Erwin M. Globio, MSIT                                                                    7-9
DB212                             CHAPTER 7: STRUCTURED QUERY LANGUAGE




         SELECT                        Columns to be projected out eventually.
         SELECT *                      To display all data in a table.
         SELECT DISTINCT               To display only one of the number of identical
                                       rows.
         SELCT <column name. .>        To display data from specific rows.
         WHERE                         Search condition for the rows.

         SQL Logical Operations
         NOT                           Select rows that do not meet the search condition.
         AND                           Both conditions must be true to qualify the row.
         OR                            One or both of the conditions must be true.

         Predicates used:
         BETWEEN                       Select column values that fall within a range.
         In                            Selects column values that match one of a
                                       number of values.
         ANY                           Select rows whose values match any of the values
                                       returned by the inner query.
         ALL                           Select rows whose values have some relation to
                                       all of the values returned by the inner query.
         EXISTS                        The EXISTS predicate determines whether the
                                       outer WHERE condition is true or false. If the
                                       inner query returns any value, the WHERE
                                       condition is true. Otherwise, the condition is
                                       false. Thus a simple subquery that uses EXISTS
                                       returns all rows if the outer WHERE condition is
                                       true.
         LIKE                          Selects column values that contain a character
                                       string
                                       Underscore (-)               - represent any single
                                       character.
                                       Percent symbol (%)           - represent no
                                       characters or a number of characters.

         GROUP BY                      Rearranges the rows extracted into partitions or
                                       groups, such that within any one group, all rows
                                       have the same value for the GROUP BY field.

         HAVING                        Conditions applied to each group from previous
                                       GROUP BY clause.

         ORDER BY                      Sort required columns either in ascending or
                                       descending order.

         Aggregate functions:          Number of values in the column
         COUNT                         Sum of the values in the column
         SUM                           Average of the values in the column
         AVG                           Largest value in the column
         MAX                           Smallest value in the column




7 - 10                                                 Prof. Erwin M. Globio, MSIT
DB212                                    CHAPTER 7: STRUCTURED QUERY LANGUAGE


          Restrict
           Restriction retrieves rows from a relation based upon selection criteria. Thus,
                 SELECT *                       (* means all columns)
                 FROM S                         (target table)
                 WHERE SCITY=                   `LONDON' ; (selection criterion)
                 will retrieve the following:


            S#          SNAME            STATUS                  CITY
            S1          SMITH            20                      LONDON
            S2          CLARK            20                      LONDON


          Project
           Projection retrieves columns form a relation based upon selection criteria. For example,
                 SELECT S#, SNAME                        (named columns)
                 FROM SUPPLIER
                 WHERE SUPPLIER.CITY = 1LONDON' ;
                 will retrieve the following:
                       S#        SNAME
                       S1        SMITH
                       S2        CLARK


           What would the following achieve?
           SELECT STATUS
           FROM SUPPLIER
           WHERE SUPPLIER.CITY = `LONDON' :
           The answer is
                                 STATUS
                               20
                               20


           Is this a proper relation? (Hint: it contains duplicate rows)
           This can be solved easily by using the command called DISTINCT, i.e.
                 SELECT DISTINCT STATUS
                 FROM SUPPLIER
                 WHERE SUPPLIER.CITY = `LONDON' ;
           which eliminates duplicates from the resultant relation.




Prof. Erwin M. Globio, MSIT                                                                  7 - 11
DB212                                     CHAPTER 7: STRUCTURED QUERY LANGUAGE


            Product
             This is an expensive operation. For example, Let S is a relation with 5 rows; P is a
             relation with 6 rows. Then the product S x P will contain 30 rows, i.e. [R1 (S)
                  R1(P), R1(S) R1(P), . . . R5(S) R6(P) ]
             The importance of product is that it provides the basis for the relational operator join.
             The following will result in a product of S, P
                 SELECT *                                       (all columns)
                            FROM SUPLIER, PART; (from both tables SUPPLIER & PART)
         Note:   Such a product is called the Cartesian product and is specifically discouraged by
                 the Relational Model. For example, if 2 tables, each has a million entries, so if
                 combined, it would tie up computing resources.
         Union
         Union can be described as a collection of columns that exist in one relation, or both. Each
         column must be of the same type and size and be drawn from the same domain. For example,
         if we look at SUPPLIER and PART tables, only one column qualifies (CITY).
                  SELECT #
                          FROM SUPLIER
                          WHERE SUPPLIER.CITY = `LONDON'
                          UNION SELECT S#
                          FROM SP
                          WHERE P# = `P2' ;
         This will extract S# for those suppliers who supply the part P2 or who are located to
         LONDON, or both. The answer is
                       S#
                       S1
                       S2
                       S3
     Duplicates are automatically eliminated. It should be noted that UNION has an associative
    property inbuilt, i.e. A UNION B and B UNION A are identical. Similarly, (A UNION B) UNION
    C is equal to (A UNION C) UNION B.
            Intersection
             Two (or more) tables which share one (or more) union-compatible attributes may be
             intersected. However, SQL requires special construct to achieve this, each involving what
             is called sub-query.
    For example, we went to list what suppliers have supplied (some) parts.
         SELCT S#
         FROM SUPPLIER
         WHERE S# IN
                 (SELECT S#
                 FROM SP) ;
         This will find all S# in SUPPLIER which match some S# in SP.




7 - 12                                                               Prof. Erwin M. Globio, MSIT
DB212                                   CHAPTER 7: STRUCTURED QUERY LANGUAGE


        Is this operation equivalent to equijoin operation?
        Note: The outer SELCT list is not restricted. Thus,
                  SELECT *
                  FROM SUPPLIER
                  WHERE S# IN
                            (SELECT S#
                            FROM SP) ;
        is perfectly fine, since only S# in SUPPLIER and S# in SP are union compatible.
        The Existential Quantifier `EXISTS".
        The above example can also be written as
                  SELECT S#
                  FROM S
                  WHERE EXISTS
                  (SELECT *
                  FROM SP
                  WHERE S.S# = SP.S#);
        Note: The `SELECT *' in the subquery does not have the meaning `select all columns'
                  as you have been as far led to believe: it mean's `scan all rows'!)
        The method of execution is as follows: `For each S# in S, scan all rows in SP until the
        expression S.S# is satisfied the search is exhausted, which ever occurs first. Return `YES' if a
        match is made, `NO' otherwise. If `YES', then the current S# in S is selected.
        In other words, `EXISTS' returns a binary valued response whereas `IN' returns a relation.
        `EXISTS" can always be used in place of `IN', but not vice versa.

           Difference
            Difference is the negation of two relation. For example,
                 SELECT S#
                 FROM SUPPLIER
                 WHERE NOT S# IN
                          (SELECT S#
                          FROM SP) ;
            (Think about: Is negation associative?)
           Divide
            For example, SP divide by PART will give S1 only.
                SP         divide by       P
                S1         P1              P1
                S1         P2              P2
                S1         P3              P3
                S1         P4              P4
                S1         P5              P5
            Since this is not commonly represented in SQL.




Prof. Erwin M. Globio, MSIT                                                                 7 - 13
DB212                                       CHAPTER 7: STRUCTURED QUERY LANGUAGE


            Join
             The purpose of a join is to create a new relation from two or more existing relations. In
             SQL, this is achieved implicitly. This is no JOIN command in SQL. There are some rules
             involved:
                   In order for two tables to be joined, they must share an attribute whose values are
                    taken from the same domain.
                   The result table must be a relation. Thus, if it has no primary key, the select list must
                    include `DISTINCT' to remove duplicate rows.
                   Where the result table may contain duplicate columns (SQL does not eliminate
                    them), the SELECT * construct is therefore discouraged.
                   The most meaningful join is one which joins a primary key to its foreign key(s).
         (Recall: Normalization helps to decompose a complex model and JOIN is used to reconstruct
         the original model.)
         For example, we want to know for all suppliers, what parts and how many they have supplied.
                  SELECT SUPPLIER.S#, SNAME, P#, QTY
                           FROM SUPPLIER, SP                              (Tables to be joined)
                           WHERE SUPPLIER.S# = SP.S#;
         If we want to extract the name of the part supplied, then
                  SELECT SUPPLIER.S#, SNAME, SP.P#,PNAME,QTY
                           FROM SUPPLIER, SP, PART
                           WHERE SUPPLIER.S# = SP.S#
                                     AND SP.P# = PART.P# ;
         We can also use the greater sign `>', or smaller sign `<', or even the not equal sign `<>' in the
         WHERE condition.




7 - 14                                                                  Prof. Erwin M. Globio, MSIT
DB212                                        CHAPTER 7: STRUCTURED QUERY LANGUAGE



7.6     Review Questions

             1.    What are the differences between equijoin and natural join. Illustrate with examples.
                                                                                                [4 marks]

        2.        a.       Answer the following questions using the below table structures.

                   Student                                    Course
                  Student-ID     Numeric       5          Course-ID       Character     5
                  Name           Character     15         Title           Character     20
                  Major          Character     3          Instructor      Character     10

                   Registration
                  Student-ID Numeric           5          Instructor
                  Name          Character      15         Instructor      Character     10
                  Major         Character      3          Location        Character     4


                   i.      Write a full database description using the SQL data definition
                           language for the above table Student.                 [2 marks]
                  ii.      Write a SQL command to add a new student "John" with student
                           number 12221 and majoring in "IT".               [1 mark]
                  iii.     Define the following view by SQL definition.            [2 marks]


                               Student-ID     Name        Major         Course-ID        Grade


                  iv.      Write a SQL command to change the grade for student number
                           38214 from 51 to 57                               [2 marks]
                  v.       Write a SQL command to display the average grade for each course.
                                                                              [3 marks]
                  vi.      Write a SQL command to count the number of students taught
                           by each instructor.                              [3 marks]
                  vii.     Write a SQL command to display an ordered list of courses and the
                           respective instructors, of which all student's grades in those courses
                           are above 50.                                            [3 marks]
        b.        Use SQL commands to illustrate:
                  i.      Natural join                                       [2 marks]              ii.
                  Search condition where exact matches are necessary [2 marks]




Prof. Erwin M. Globio, MSIT                                                                    7 - 15
DB212                    CHAPTER 7: STRUCTURED QUERY LANGUAGE




Useful Websites to learn Database and Programming:



http://erwinglobio.wix.com/ittraining
http://ittrainingsolutions.webs.com/
http://erwinglobio.sulit.com.ph/
http://erwinglobio.multiply.com/




7 - 16                                   Prof. Erwin M. Globio, MSIT

Weitere ähnliche Inhalte

Was ist angesagt?

Decomposition using Functional Dependency
Decomposition using Functional DependencyDecomposition using Functional Dependency
Decomposition using Functional DependencyRaj Naik
 
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2Philip Schwarz
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionsNicole Ryan
 
Fd & Normalization - Database Management System
Fd & Normalization - Database Management SystemFd & Normalization - Database Management System
Fd & Normalization - Database Management SystemDrishti Bhalla
 
LDA/TagLDA In Slow Motion
LDA/TagLDA In Slow MotionLDA/TagLDA In Slow Motion
LDA/TagLDA In Slow MotionPradipto Das
 
Functional dependencies and normalization
Functional dependencies and normalizationFunctional dependencies and normalization
Functional dependencies and normalizationdaxesh chauhan
 
Oracle database tips
Oracle database tipsOracle database tips
Oracle database tipssriram raj
 
Chapter 13.1.3
Chapter 13.1.3Chapter 13.1.3
Chapter 13.1.3patcha535
 
Doppl development iteration #9
Doppl development   iteration #9Doppl development   iteration #9
Doppl development iteration #9Diego Perini
 
The Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database ConstraintsThe Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database Constraintssontumax
 
Database Management System Review
Database Management System ReviewDatabase Management System Review
Database Management System ReviewKaya Ota
 
Functional dependency and normalization
Functional dependency and normalizationFunctional dependency and normalization
Functional dependency and normalizationUniversity of Potsdam
 
Functional dependancy
Functional dependancyFunctional dependancy
Functional dependancyVisakh V
 
Decaf language specification
Decaf language specificationDecaf language specification
Decaf language specificationSami Said
 
Ggplot2 work
Ggplot2 workGgplot2 work
Ggplot2 workARUN DN
 

Was ist angesagt? (19)

Bab 6 pendukung
Bab 6 pendukungBab 6 pendukung
Bab 6 pendukung
 
Ch3
Ch3Ch3
Ch3
 
Decomposition using Functional Dependency
Decomposition using Functional DependencyDecomposition using Functional Dependency
Decomposition using Functional Dependency
 
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Fd & Normalization - Database Management System
Fd & Normalization - Database Management SystemFd & Normalization - Database Management System
Fd & Normalization - Database Management System
 
LDA/TagLDA In Slow Motion
LDA/TagLDA In Slow MotionLDA/TagLDA In Slow Motion
LDA/TagLDA In Slow Motion
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
Functional dependencies and normalization
Functional dependencies and normalizationFunctional dependencies and normalization
Functional dependencies and normalization
 
Oracle database tips
Oracle database tipsOracle database tips
Oracle database tips
 
Chapter 13.1.3
Chapter 13.1.3Chapter 13.1.3
Chapter 13.1.3
 
Doppl development iteration #9
Doppl development   iteration #9Doppl development   iteration #9
Doppl development iteration #9
 
The Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database ConstraintsThe Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database Constraints
 
Database Management System Review
Database Management System ReviewDatabase Management System Review
Database Management System Review
 
Functional dependency and normalization
Functional dependency and normalizationFunctional dependency and normalization
Functional dependency and normalization
 
Functional dependancy
Functional dependancyFunctional dependancy
Functional dependancy
 
Decaf language specification
Decaf language specificationDecaf language specification
Decaf language specification
 
P J020
P J020P J020
P J020
 
Ggplot2 work
Ggplot2 workGgplot2 work
Ggplot2 work
 

Andere mochten auch

Solutions to Common Android Problems
Solutions to Common Android ProblemsSolutions to Common Android Problems
Solutions to Common Android ProblemsProf. Erwin Globio
 
iOS Apps Development (SQLite Tutorial Part 2)
iOS Apps Development (SQLite Tutorial Part 2)iOS Apps Development (SQLite Tutorial Part 2)
iOS Apps Development (SQLite Tutorial Part 2)Prof. Erwin Globio
 
Introduction to Android Development Latest
Introduction to Android Development LatestIntroduction to Android Development Latest
Introduction to Android Development LatestProf. Erwin Globio
 
iOS Apps Development (SQLite Tutorial Part 1)
iOS Apps Development (SQLite Tutorial Part 1)iOS Apps Development (SQLite Tutorial Part 1)
iOS Apps Development (SQLite Tutorial Part 1)Prof. Erwin Globio
 
Database Development Strategies
Database Development StrategiesDatabase Development Strategies
Database Development StrategiesProf. Erwin Globio
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android DevelopmentProf. Erwin Globio
 
Ideas for Writing a Conclusion
Ideas for Writing a ConclusionIdeas for Writing a Conclusion
Ideas for Writing a Conclusionlarchmeany1
 
Mobile Enterprise Trends 2015 - Emergence Capital
Mobile Enterprise Trends 2015 - Emergence CapitalMobile Enterprise Trends 2015 - Emergence Capital
Mobile Enterprise Trends 2015 - Emergence CapitalEmergence Capital
 

Andere mochten auch (20)

PSITE Letter for Prof Globio
PSITE Letter for Prof GlobioPSITE Letter for Prof Globio
PSITE Letter for Prof Globio
 
Solutions to Common Android Problems
Solutions to Common Android ProblemsSolutions to Common Android Problems
Solutions to Common Android Problems
 
iOS Apps Development (SQLite Tutorial Part 2)
iOS Apps Development (SQLite Tutorial Part 2)iOS Apps Development (SQLite Tutorial Part 2)
iOS Apps Development (SQLite Tutorial Part 2)
 
Embedded System Presentation
Embedded System PresentationEmbedded System Presentation
Embedded System Presentation
 
FND COMP Project Guidelines
FND COMP Project GuidelinesFND COMP Project Guidelines
FND COMP Project Guidelines
 
Introduction to Android Development Latest
Introduction to Android Development LatestIntroduction to Android Development Latest
Introduction to Android Development Latest
 
iOS Apps Development (SQLite Tutorial Part 1)
iOS Apps Development (SQLite Tutorial Part 1)iOS Apps Development (SQLite Tutorial Part 1)
iOS Apps Development (SQLite Tutorial Part 1)
 
Android Fragments
Android FragmentsAndroid Fragments
Android Fragments
 
A tutorial on C++ Programming
A tutorial on C++ ProgrammingA tutorial on C++ Programming
A tutorial on C++ Programming
 
Eclipse vs Netbeans
Eclipse vs NetbeansEclipse vs Netbeans
Eclipse vs Netbeans
 
Internet of Things
Internet of ThingsInternet of Things
Internet of Things
 
Networking Trends
Networking TrendsNetworking Trends
Networking Trends
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1
 
Database Development Strategies
Database Development StrategiesDatabase Development Strategies
Database Development Strategies
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Project Proposal Guidelines
Project Proposal GuidelinesProject Proposal Guidelines
Project Proposal Guidelines
 
Ideas for Writing a Conclusion
Ideas for Writing a ConclusionIdeas for Writing a Conclusion
Ideas for Writing a Conclusion
 
Mobile Enterprise Trends 2015 - Emergence Capital
Mobile Enterprise Trends 2015 - Emergence CapitalMobile Enterprise Trends 2015 - Emergence Capital
Mobile Enterprise Trends 2015 - Emergence Capital
 
Thesis Writing
Thesis WritingThesis Writing
Thesis Writing
 
BSCS | BSIT Thesis Guidelines
BSCS | BSIT Thesis GuidelinesBSCS | BSIT Thesis Guidelines
BSCS | BSIT Thesis Guidelines
 

Ähnlich wie Structured Query Language

Dbms important questions and answers
Dbms important questions and answersDbms important questions and answers
Dbms important questions and answersLakshmiSarvani6
 
AWS July Webinar Series - Getting Started with Amazon DynamoDB
AWS July Webinar Series - Getting Started with Amazon DynamoDBAWS July Webinar Series - Getting Started with Amazon DynamoDB
AWS July Webinar Series - Getting Started with Amazon DynamoDBAmazon Web Services
 
Structure Query Language (SQL).pptx
Structure Query Language (SQL).pptxStructure Query Language (SQL).pptx
Structure Query Language (SQL).pptxNalinaKumari2
 
Structure query language (sql)
Structure query language (sql)Structure query language (sql)
Structure query language (sql)Nalina Kumari
 
Islamic University Previous Year Question Solution 2019 (ADBMS)
Islamic University Previous Year Question Solution 2019 (ADBMS)Islamic University Previous Year Question Solution 2019 (ADBMS)
Islamic University Previous Year Question Solution 2019 (ADBMS)Rakibul Hasan Pranto
 
Towards a New Data Modelling Architecture - Part 1
Towards a New Data Modelling Architecture - Part 1Towards a New Data Modelling Architecture - Part 1
Towards a New Data Modelling Architecture - Part 1JEAN-MICHEL LETENNIER
 
SQL for PHP Programmers -- Dallas PHP Users Group Jan 2015
SQL for PHP Programmers -- Dallas PHP Users Group Jan 2015SQL for PHP Programmers -- Dallas PHP Users Group Jan 2015
SQL for PHP Programmers -- Dallas PHP Users Group Jan 2015Dave Stokes
 
Oracle interview questions
Oracle interview questionsOracle interview questions
Oracle interview questionsbarbie0909
 
6 integrity and security
6 integrity and security6 integrity and security
6 integrity and securityDilip G R
 
Lecture 13
Lecture 13Lecture 13
Lecture 13Shani729
 
Lecture 3: Data-Intensive Computing for Text Analysis (Fall 2011)
Lecture 3: Data-Intensive Computing for Text Analysis (Fall 2011)Lecture 3: Data-Intensive Computing for Text Analysis (Fall 2011)
Lecture 3: Data-Intensive Computing for Text Analysis (Fall 2011)Matthew Lease
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational modelChirag vasava
 

Ähnlich wie Structured Query Language (20)

Dbms important questions and answers
Dbms important questions and answersDbms important questions and answers
Dbms important questions and answers
 
AWS July Webinar Series - Getting Started with Amazon DynamoDB
AWS July Webinar Series - Getting Started with Amazon DynamoDBAWS July Webinar Series - Getting Started with Amazon DynamoDB
AWS July Webinar Series - Getting Started with Amazon DynamoDB
 
Structure Query Language (SQL).pptx
Structure Query Language (SQL).pptxStructure Query Language (SQL).pptx
Structure Query Language (SQL).pptx
 
Structure query language (sql)
Structure query language (sql)Structure query language (sql)
Structure query language (sql)
 
T-SQL Overview
T-SQL OverviewT-SQL Overview
T-SQL Overview
 
vb.net.pdf
vb.net.pdfvb.net.pdf
vb.net.pdf
 
Islamic University Previous Year Question Solution 2019 (ADBMS)
Islamic University Previous Year Question Solution 2019 (ADBMS)Islamic University Previous Year Question Solution 2019 (ADBMS)
Islamic University Previous Year Question Solution 2019 (ADBMS)
 
Towards a New Data Modelling Architecture - Part 1
Towards a New Data Modelling Architecture - Part 1Towards a New Data Modelling Architecture - Part 1
Towards a New Data Modelling Architecture - Part 1
 
SQL for PHP Programmers -- Dallas PHP Users Group Jan 2015
SQL for PHP Programmers -- Dallas PHP Users Group Jan 2015SQL for PHP Programmers -- Dallas PHP Users Group Jan 2015
SQL for PHP Programmers -- Dallas PHP Users Group Jan 2015
 
FinalReport
FinalReportFinalReport
FinalReport
 
Oracle interview questions
Oracle interview questionsOracle interview questions
Oracle interview questions
 
6 integrity and security
6 integrity and security6 integrity and security
6 integrity and security
 
RDBMS
RDBMSRDBMS
RDBMS
 
Viva voce
Viva voceViva voce
Viva voce
 
Lecture 13
Lecture 13Lecture 13
Lecture 13
 
4.Database Management System.pdf
4.Database Management System.pdf4.Database Management System.pdf
4.Database Management System.pdf
 
NoSQL - Leo's notes
NoSQL - Leo's notesNoSQL - Leo's notes
NoSQL - Leo's notes
 
Lecture 3: Data-Intensive Computing for Text Analysis (Fall 2011)
Lecture 3: Data-Intensive Computing for Text Analysis (Fall 2011)Lecture 3: Data-Intensive Computing for Text Analysis (Fall 2011)
Lecture 3: Data-Intensive Computing for Text Analysis (Fall 2011)
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 
PO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - SqlPO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - Sql
 

Mehr von Prof. Erwin Globio

Mehr von Prof. Erwin Globio (16)

Sq lite presentation
Sq lite presentationSq lite presentation
Sq lite presentation
 
Ethics for IT Professionals
Ethics for IT ProfessionalsEthics for IT Professionals
Ethics for IT Professionals
 
Cisco Router Basic Configuration
Cisco Router Basic ConfigurationCisco Router Basic Configuration
Cisco Router Basic Configuration
 
Introduction to iOS Apps Development
Introduction to iOS Apps DevelopmentIntroduction to iOS Apps Development
Introduction to iOS Apps Development
 
Cloud Computing Latest
Cloud Computing LatestCloud Computing Latest
Cloud Computing Latest
 
Overview of C Language
Overview of C LanguageOverview of C Language
Overview of C Language
 
Introduction to Computer Programming
Introduction to Computer ProgrammingIntroduction to Computer Programming
Introduction to Computer Programming
 
Android Development Tools and Installation
Android Development Tools and InstallationAndroid Development Tools and Installation
Android Development Tools and Installation
 
Java Collections Tutorials
Java Collections TutorialsJava Collections Tutorials
Java Collections Tutorials
 
Action Bar in Android
Action Bar in AndroidAction Bar in Android
Action Bar in Android
 
Resource Speaker
Resource SpeakerResource Speaker
Resource Speaker
 
Guidelines to Qualitative Researches
Guidelines to Qualitative ResearchesGuidelines to Qualitative Researches
Guidelines to Qualitative Researches
 
Lecture on E-Presentation
Lecture on E-PresentationLecture on E-Presentation
Lecture on E-Presentation
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
Human Resource Management Seminar
Human Resource Management SeminarHuman Resource Management Seminar
Human Resource Management Seminar
 
The Best in Internet Marketing
The Best in Internet MarketingThe Best in Internet Marketing
The Best in Internet Marketing
 

Kürzlich hochgeladen

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 

Kürzlich hochgeladen (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 

Structured Query Language

  • 1. CHAPTER : STRUCTURED QUERY LANGUAGE Chapter Objectives At the end of this chapter, you should be able to:  understand the general concepts of the relational model;  explain the common integrity rules. Essential Reading An introduction to Database System Volume I (5th Edition), C.J.Date (1990), Addison Wesley. [Chapter 11 - 12] Modem Database Management (4th Edition), Fred McFadden & Jeffrey A. Hoffer (1994), Benjamin/Cummings. [Chapter 8, page 283-316] Useful Websites to learn Database and Programming: http://erwinglobio.wix.com/ittraining http://ittrainingsolutions.webs.com/ http://erwinglobio.sulit.com.ph/ http://erwinglobio.multiply.com/ Prof. Erwin M. Globio, MSIT 7-1
  • 2. DB212 CHAPTER 7: STRUCTURED QUERY LANGUAGE 7-2 Prof. Erwin M. Globio, MSIT
  • 3. DB212 CHAPTER 7: STRUCTURED QUERY LANGUAGE 7.1 Relational Data Structures and Concepts Two-dimensional tables whose attributes values are atomic. This is to say that at every row-and-column position within the table, there always exists precisely one value, never a list of values. (Recalls: Relations do not contain repeating groups after INF.) There are no duplicate rows. (Recall: There is always a primary key in a relation.) Rows (tuples) are unordered. S# SNAME STATUS CITY S1 Smith 21 London S2 Jones 10 Paris S3 Mary 30 Paris S4 Clark 20 Athens <----------------------------------- Degree -------------------------------------> Degree of a relation is the number of attributes in a relation. Cardinality of a relation is the number of tuples in a relation. Domain is a pool of values, from which one of more attributes draw their actual values. For example, a domain of supplier numbers is the set of all possible supplier numbers and the domain. 7.2 Integrity Rules  The entity integrity rules No component of the primary key of a relation is allowed to accept nulls. Bu "null", we mean that information is missing for some reason. Suppose in the supplier relation, there is a tuple for which the supplier-no is null. This would be like saying that there was a supplier in the real world that had no identity. This is absurd.  The referential integrity rule The database must not contain any unmatched foreign key values. By the term "unmatched foreign key value", we mean a non-null foreign key value for which there does not exist a matching value of the primary key in the relevant target relation.  The referential integrity rule says that if B references A, then A must exist. Note: Foreign key and referential integrity concepts are defined in terms of one another. Thus, "support for referential integrity" and "support for foreign keys" mean exactly the same thing.) The basic idea is as follows: For each foreign key, there are three questions that need to be answered:  Can that foreign key accept nulls? For example, does it make sense for a shipment to exist for which the supplier is unknown? Prof. Erwin M. Globio, MSIT 7-3
  • 4. DB212 CHAPTER 7: STRUCTURED QUERY LANGUAGE  What should happen on an attempt to delete the target of a foreign key references? For example, an attempt to delete a supplier for which there exists at least at one matching shipment? Let us consider more definitely the following cases: Restricted The delete operation is "restricted" to the case where there are no such matching shipments (it is rejected otherwise) Cascades The delete operation "cascades" to delete those matching shipments also Nullifies The foreign key is set to null in all such matching shipments and the supplier is then deleted (of course, this case could not apply if the foreign key cannot accept nulls in the first place)  What should happen on an attempt to update the primary key of a foreign key reference? For example, an attempt to update the supplier number for a supplier for which there exists at least one matching shipment? Let us consider the following cases: Restricted The update operation is "restricted" to the case where there are no such matching shipments (it is rejected otherwise) Cascades The update operation "cascades" to updates the foreign key in those matching shipments also Nullifies The foreign key is set to null in all such matching shipments and the supplier is then updated (of course, this case could not apply if the foreign cannot accept nulls in the first place) Note: Restricted-Cascaded-Nullifies options for the foreign key delete and update rules do not exhaust the possibilities. They are just common practices. 7.3 SQL and Relational Model SQL (Structured Query Language) is a relational language, which provides an interface between the user and the RDBMS 7.3.1 A Brief Decomposition SQL's capabilities are divided between the data description language (DDL) and the data manipulation language (DML). DDL Create tables Query table data Modify tables (ALTER) Modify table data Create indexes - Insert Drop tables - Delete Drop indexes - Update Authorization (GRANT) Aggregate functions Deauthorisation (REVOKE) 7-4 Prof. Erwin M. Globio, MSIT
  • 5. DB212 CHAPTER 7: STRUCTURED QUERY LANGUAGE The purpose of the DDL is to create entries in the catalogue (sometimes called the data dictionary or, in some large systems, the repository). The catalogue is managed by the RDBMS and it is a requirement of the Relational Model that the catalogue itself takes the form of normalized tables. The update of these tables is quite transparent to the user. 7.4 Relational Data Definition Insql (DDL) Data Types DECIMAL (m,n) Signed numbers, where m is the total number of digits to the right of the decimal point. INTEGER Large (up to 11 digits) positive or negative whole numbers SMALL Small (5 or 6 digits, depending on the DBMS) positive or negative whole numbers. By specifying this data type, less storage space is required FLOAT (m,n) Whole and fractional numbers represented in scientific notation, where m is the total number of digits (including sign), and n is the number of digits to the right of the decimal point. CHAR (n) Alphanumeric (character) data, where n is the maximum length for the character string; n character positions are allocated to each instance of a CHAR column. DATE Calendar dates. A system variable can be used to set the format for the date data type. LOGICAL True or false values DDL Commands Description CREATE TABLE Define the structure of a new table INSERT Places a new row in a table based on values supplied in the statement, copies one or more rows derived from other database into a table, extracts data from one table and inserts them into another. UPDATE Changes values in one or more specified rows of a table by replacing current values with constant or the results of calculation. DELETE Removes one of more rows from a table. CREATE VIEW Names the view and optionally specifies column names to be used in place of those of the base table. CREATE INDEX Defines an index on one column that enables rapid access to the rows of a table in a sequence or randomly by the key value. ALTER TABLE Adds columns to an existing. DROP TABLE Deletes table. DROP INDEXES Deletes index. GRANT Granting user access. REVOKE Removing privileges given to a user. (DBA privileges) Prof. Erwin M. Globio, MSIT 7-5
  • 6. DB212 CHAPTER 7: STRUCTURED QUERY LANGUAGE Illustrations: The following is the suppliers-parts-projects database SUPPLIER PROJECTS S# SNAME STATUS CITY J# JNAME CITY S1 SMITH 20 LONDON J1 SORTER PARIS S2 JONES 10 PARIS J2 PUNCH ROME S3 BLAKE 30 PARIS J3 READER ATHENS S4 CLARK 20 LONDON J4 CONSOLE ATHENS S5 ADAMS 30 ATHENS J5 COLLATOR LONDON J6 TERMINAL OSLO J7 TAPE LONDON PART P# PNAME COLOR WEIGHT CITY P1 NUT RED 12 LONDON P2 BOLT GREEN 17 PARIS P3 SCREW BLUE 17 ROME P4 SCREW RED 14 LONDON P5 CAM BLUE 14 PARIS P6 COQ RED 19 LONDON S# P# J# QTY S# P# QTY S1 P1 J1 200 S1 P1 300 S1 P1 J4 700 S1 P2 200 S2 P3 J1 400 S1 P3 400 S2 P3 J2 200 S1 P4 200 S2 P3 J3 200 S1 P5 100 S2 P3 J4 500 S1 P6 100 S2 P3 J5 600 S2 P1 300 S2 P3 J6 400 S2 P2 400 S2 P3 J7 800 S3 P2 200 S2 P5 J2 100 S4 P2 200 S3 P3 J1 200 S4 P4 300 S3 P4 J2 500 S4 P5 400 S4 P6 J3 300 S5 P6 J7 300 S5 P6 J2 200 S5 P1 J4 100 S5 P3 J4 200 S5 P4 J4 800 S5 P5 J4 400 S5 P6 J4 500 7-6 Prof. Erwin M. Globio, MSIT
  • 7. DB212 CHAPTER 7: STRUCTURED QUERY LANGUAGE Example:  Adding data to a table  Adding of one new row to a table INSERT INTO SUPPLIE VALUES ( "S6", "MARY" , 30, "NEW YORK" ) ;  Transferring rows from external file to a database table INSERT INTO SUPPLIER SELECT * FROM NEW-SUPPLIER WHERE STATUS >20 ;  Deleting database contents Rows can be deleted individually or in groups.  Deleting a row from a table DELETE FROM PART WHERE WEIGHT = 12 ;  Deleting all rows of a table DELETE FROM PART ; Note: Deletion must be done with care when rows from several relations are involved. For example, if we deleted a SUPPLIER row or a PROJECT row, or a PART row, we will have a referential integrity violation in the SPJ or SP tables.)  Changing database contents To update data in SQL, we must inform the DBMS what relation, columns and rows are involved. UPDATE SUPPLIER SET CITY = ROME WHERE SUPPLIER-NO = "S3" ;  Constructing a View for more than one table A view is also called a virtual table because it does not actually contain stored data, combines data that is selected from one or more base tables of the other views. If the data in the base tables changes, so does the information displayed using the view. We can use a view to let someone access just the rows and columns that the person needs from base tables. We can omit columns containing irrelevant or sensitive information. For instance, CREATE VIEW SUPPLIER-PART (SUPPLIER-NO, PART-NO,QUANTITY) AS SELECT S#, P#, QTY FROM SP WHERE QTY > = 200; Prof. Erwin M. Globio, MSIT 7-7
  • 8. DB212 CHAPTER 7: STRUCTURED QUERY LANGUAGE This will create an external presentation to the user on the table SP. CREATE VIEW DEALS (SUPPLIER-NAME, CITY, PROJRCT) AS SELECT SNAME, SUPPLIER. CITY, JNAME FROM SUPPLIER, PROJECT WHERE SUPPLIER, CITY = PROJECT. CITY; This view links suppliers with the project. The two tables are related using their common CITY column.  Creating indexes You can create indexes in most RDBMSs to provide rapid random and sequential access to base-table data. For example, to create an index on the supplier table for the S#: CREATE INDEX S-NO ON SUPPLIER (S#);  Changing table definitions We may change table definitions in many SQL RDBMSs by ALTERING column specifications. For example, to add a new column ADDRESS in the SUPPLIER table: ALTER TABLE SUPPLIER ADD (ADDRESS CHAR (30) ) ;  Deleting tables Once a table is deleted, all the data will be deleted permanently and you cannot get it back. DROP VIEW tablename;  Deleting views Here, the TABLES(s) on which the VIEW is based will not be changed. DROP INDEX indexname; 7-8 Prof. Erwin M. Globio, MSIT
  • 9. DB212 CHAPTER 7: STRUCTURED QUERY LANGUAGE 7.5 Basic SQL Construct (DML) SQL's DML is divided into two parts, retrieval commands and updates commands. The following are the eight operators used by the RM (Relational Model) for retrieval of data from normalized relations: Restrict Project a X a x b y b y c c x a y b x c y Union Intersection Difference These represent the eight original operators used by the relational model for retrieval model for retrieval of data from normalization relations. Product, union, insertion and difference are operators in a branch of mathematics called set theory. Restrict, project, join and divide are operators in a branch of mathematics called relational theory. Prof. Erwin M. Globio, MSIT 7-9
  • 10. DB212 CHAPTER 7: STRUCTURED QUERY LANGUAGE SELECT Columns to be projected out eventually. SELECT * To display all data in a table. SELECT DISTINCT To display only one of the number of identical rows. SELCT <column name. .> To display data from specific rows. WHERE Search condition for the rows. SQL Logical Operations NOT Select rows that do not meet the search condition. AND Both conditions must be true to qualify the row. OR One or both of the conditions must be true. Predicates used: BETWEEN Select column values that fall within a range. In Selects column values that match one of a number of values. ANY Select rows whose values match any of the values returned by the inner query. ALL Select rows whose values have some relation to all of the values returned by the inner query. EXISTS The EXISTS predicate determines whether the outer WHERE condition is true or false. If the inner query returns any value, the WHERE condition is true. Otherwise, the condition is false. Thus a simple subquery that uses EXISTS returns all rows if the outer WHERE condition is true. LIKE Selects column values that contain a character string Underscore (-) - represent any single character. Percent symbol (%) - represent no characters or a number of characters. GROUP BY Rearranges the rows extracted into partitions or groups, such that within any one group, all rows have the same value for the GROUP BY field. HAVING Conditions applied to each group from previous GROUP BY clause. ORDER BY Sort required columns either in ascending or descending order. Aggregate functions: Number of values in the column COUNT Sum of the values in the column SUM Average of the values in the column AVG Largest value in the column MAX Smallest value in the column 7 - 10 Prof. Erwin M. Globio, MSIT
  • 11. DB212 CHAPTER 7: STRUCTURED QUERY LANGUAGE  Restrict Restriction retrieves rows from a relation based upon selection criteria. Thus, SELECT * (* means all columns) FROM S (target table) WHERE SCITY= `LONDON' ; (selection criterion) will retrieve the following: S# SNAME STATUS CITY S1 SMITH 20 LONDON S2 CLARK 20 LONDON  Project Projection retrieves columns form a relation based upon selection criteria. For example, SELECT S#, SNAME (named columns) FROM SUPPLIER WHERE SUPPLIER.CITY = 1LONDON' ; will retrieve the following: S# SNAME S1 SMITH S2 CLARK What would the following achieve? SELECT STATUS FROM SUPPLIER WHERE SUPPLIER.CITY = `LONDON' : The answer is STATUS 20 20 Is this a proper relation? (Hint: it contains duplicate rows) This can be solved easily by using the command called DISTINCT, i.e. SELECT DISTINCT STATUS FROM SUPPLIER WHERE SUPPLIER.CITY = `LONDON' ; which eliminates duplicates from the resultant relation. Prof. Erwin M. Globio, MSIT 7 - 11
  • 12. DB212 CHAPTER 7: STRUCTURED QUERY LANGUAGE  Product This is an expensive operation. For example, Let S is a relation with 5 rows; P is a relation with 6 rows. Then the product S x P will contain 30 rows, i.e. [R1 (S) R1(P), R1(S) R1(P), . . . R5(S) R6(P) ] The importance of product is that it provides the basis for the relational operator join. The following will result in a product of S, P SELECT * (all columns) FROM SUPLIER, PART; (from both tables SUPPLIER & PART) Note: Such a product is called the Cartesian product and is specifically discouraged by the Relational Model. For example, if 2 tables, each has a million entries, so if combined, it would tie up computing resources. Union Union can be described as a collection of columns that exist in one relation, or both. Each column must be of the same type and size and be drawn from the same domain. For example, if we look at SUPPLIER and PART tables, only one column qualifies (CITY). SELECT # FROM SUPLIER WHERE SUPPLIER.CITY = `LONDON' UNION SELECT S# FROM SP WHERE P# = `P2' ; This will extract S# for those suppliers who supply the part P2 or who are located to LONDON, or both. The answer is S# S1 S2 S3 Duplicates are automatically eliminated. It should be noted that UNION has an associative property inbuilt, i.e. A UNION B and B UNION A are identical. Similarly, (A UNION B) UNION C is equal to (A UNION C) UNION B.  Intersection Two (or more) tables which share one (or more) union-compatible attributes may be intersected. However, SQL requires special construct to achieve this, each involving what is called sub-query. For example, we went to list what suppliers have supplied (some) parts. SELCT S# FROM SUPPLIER WHERE S# IN (SELECT S# FROM SP) ; This will find all S# in SUPPLIER which match some S# in SP. 7 - 12 Prof. Erwin M. Globio, MSIT
  • 13. DB212 CHAPTER 7: STRUCTURED QUERY LANGUAGE Is this operation equivalent to equijoin operation? Note: The outer SELCT list is not restricted. Thus, SELECT * FROM SUPPLIER WHERE S# IN (SELECT S# FROM SP) ; is perfectly fine, since only S# in SUPPLIER and S# in SP are union compatible. The Existential Quantifier `EXISTS". The above example can also be written as SELECT S# FROM S WHERE EXISTS (SELECT * FROM SP WHERE S.S# = SP.S#); Note: The `SELECT *' in the subquery does not have the meaning `select all columns' as you have been as far led to believe: it mean's `scan all rows'!) The method of execution is as follows: `For each S# in S, scan all rows in SP until the expression S.S# is satisfied the search is exhausted, which ever occurs first. Return `YES' if a match is made, `NO' otherwise. If `YES', then the current S# in S is selected. In other words, `EXISTS' returns a binary valued response whereas `IN' returns a relation. `EXISTS" can always be used in place of `IN', but not vice versa.  Difference Difference is the negation of two relation. For example, SELECT S# FROM SUPPLIER WHERE NOT S# IN (SELECT S# FROM SP) ; (Think about: Is negation associative?)  Divide For example, SP divide by PART will give S1 only. SP divide by P S1 P1 P1 S1 P2 P2 S1 P3 P3 S1 P4 P4 S1 P5 P5 Since this is not commonly represented in SQL. Prof. Erwin M. Globio, MSIT 7 - 13
  • 14. DB212 CHAPTER 7: STRUCTURED QUERY LANGUAGE  Join The purpose of a join is to create a new relation from two or more existing relations. In SQL, this is achieved implicitly. This is no JOIN command in SQL. There are some rules involved:  In order for two tables to be joined, they must share an attribute whose values are taken from the same domain.  The result table must be a relation. Thus, if it has no primary key, the select list must include `DISTINCT' to remove duplicate rows.  Where the result table may contain duplicate columns (SQL does not eliminate them), the SELECT * construct is therefore discouraged.  The most meaningful join is one which joins a primary key to its foreign key(s). (Recall: Normalization helps to decompose a complex model and JOIN is used to reconstruct the original model.) For example, we want to know for all suppliers, what parts and how many they have supplied. SELECT SUPPLIER.S#, SNAME, P#, QTY FROM SUPPLIER, SP (Tables to be joined) WHERE SUPPLIER.S# = SP.S#; If we want to extract the name of the part supplied, then SELECT SUPPLIER.S#, SNAME, SP.P#,PNAME,QTY FROM SUPPLIER, SP, PART WHERE SUPPLIER.S# = SP.S# AND SP.P# = PART.P# ; We can also use the greater sign `>', or smaller sign `<', or even the not equal sign `<>' in the WHERE condition. 7 - 14 Prof. Erwin M. Globio, MSIT
  • 15. DB212 CHAPTER 7: STRUCTURED QUERY LANGUAGE 7.6 Review Questions 1. What are the differences between equijoin and natural join. Illustrate with examples. [4 marks] 2. a. Answer the following questions using the below table structures. Student Course Student-ID Numeric 5 Course-ID Character 5 Name Character 15 Title Character 20 Major Character 3 Instructor Character 10 Registration Student-ID Numeric 5 Instructor Name Character 15 Instructor Character 10 Major Character 3 Location Character 4 i. Write a full database description using the SQL data definition language for the above table Student. [2 marks] ii. Write a SQL command to add a new student "John" with student number 12221 and majoring in "IT". [1 mark] iii. Define the following view by SQL definition. [2 marks] Student-ID Name Major Course-ID Grade iv. Write a SQL command to change the grade for student number 38214 from 51 to 57 [2 marks] v. Write a SQL command to display the average grade for each course. [3 marks] vi. Write a SQL command to count the number of students taught by each instructor. [3 marks] vii. Write a SQL command to display an ordered list of courses and the respective instructors, of which all student's grades in those courses are above 50. [3 marks] b. Use SQL commands to illustrate: i. Natural join [2 marks] ii. Search condition where exact matches are necessary [2 marks] Prof. Erwin M. Globio, MSIT 7 - 15
  • 16. DB212 CHAPTER 7: STRUCTURED QUERY LANGUAGE Useful Websites to learn Database and Programming: http://erwinglobio.wix.com/ittraining http://ittrainingsolutions.webs.com/ http://erwinglobio.sulit.com.ph/ http://erwinglobio.multiply.com/ 7 - 16 Prof. Erwin M. Globio, MSIT