1 / 16

Structured Query Language (SQL)

Structured Query Language (SQL). BOOK RELATION. CREATE TABLE SYNTAX. CREATE TABLE <RELATION NAME> ( <ATTRIBUTE> <TYPE> [NOT NULL], <ATTRIBUTE> <TYPE> [NOT NULL], ... CONSTRAINT PRIMARY KEY (<ATTRIBUTE(S)>) [,] [ FOREIGN KEY (<ATTRIBUTE(S)>)

eunice
Télécharger la présentation

Structured Query Language (SQL)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Structured Query Language(SQL)

  2. BOOK RELATION

  3. CREATE TABLE SYNTAX CREATE TABLE <RELATION NAME> ( <ATTRIBUTE> <TYPE> [NOT NULL], <ATTRIBUTE> <TYPE> [NOT NULL], ... CONSTRAINT PRIMARY KEY (<ATTRIBUTE(S)>) [,] [FOREIGN KEY (<ATTRIBUTE(S)>) REFERENCES <RELATION> (<ATTRIBUTE(S)>)] [,] [FOREIGN KEY (<ATTRIBUTE(S)>) REFERENCES <RELATION> (<ATTRIBUTE(S)>)] ... )

  4. SUPPLY DATABASE

  5. EMPLOYEE & DEPARTMENT RELATIONS EMPLOYEE DEPARTMENT

  6. SQL FOR GET NAMES OF DEPARMENT MANAGERS SELECT NAME FROM EMPLOYEE, DEPARTMENT WHERE EMPLOYEE.SSN = DEPARTMENT.MGRSSN

  7. CARTESIAN PRODUCT OF FROM CLAUSE

  8. CARTESIAN PRODUCT FILTERED BY WHERE CLAUSE

  9. PROJECT DOWN TO ATTRIBUTES IN SELECT CLAUSE

  10. People The PEOPLE Relation

  11. Result SELECT Name, Age FROM People WHERE Dependents = 0 ORDER BY Age DESC, Name ASC Ordering Query Results

  12. People SELECT Age, COUNT(*) FROM People GROUP BY Age The PEOPLE Relation Partitioned Into Groups

  13. Intermediary table for LEFT OUTER JOIN QUERY: SELECT SNAME, P# FROM S, (SELECT * FROM SPJ WHERE J#=‘J1’) SPJ1 WHERE S.S#=SPJ.S# (+)

  14. TRIGGERS: LEDGER and LEDGER_AUDIT TABLES LEDGER LEDGER_AUDIT

  15. TRIGGERS: EXAMPLE create trigger ledger_update before update on LEDGER for each row when ((new.Amount/old.Amount)>1.1) begin insert into LEDGER_AUDIT values (:old.ActionDate, :old.Action, :old.Item, :old.Quantity, :old.QuantityType, :old.Cost, :old.Total, :old.Person); end;

  16. TRIGGERS: SYNTAX

More Related