SlideShare ist ein Scribd-Unternehmen logo
1 von 54
Downloaden Sie, um offline zu lesen
SQL – deel 1


Katrien Verbert en Joris Klerkx
katrien.verbert@cs.kuleuven.be
joris.klerkx@cs.kuleuven.be
geschiedenis

•  SEQUEL (Structured English Query Language)
   –  voor experimentele gegevensbank "System R" (IBM)
•  → SQL (Structured Query Language)
   –  voor DB2, Oracle, INGRES/SQL, ...
   –  eerste commerciële versie: Oracle in 1979




                                                         2
standaardisatie: ANSI - ISO

•  SQL1 : 1986
•  SQL2 of SQL92 : 1992
   –  “levels of conformance”: entry – intemediate - full
•  SQL99 : 1999
   –  aanvullingen met o.a. nieuwe data types, object-georiënteerde
      concepten en triggers
   –  levels of conformance: Core SQL:1999 - Enhanced SQL:1999

 de meeste implementaties van SQL verschillen in meer
 of mindere mate van de standaard



                                                                      3
SQL 2003
•    ongeveer zelfde Core als SQL99
•    nieuwe object-relationele features (multiset, array types, etc.)
•    XML-gerelateerde features (SQL/XML)
•    meer functies (sequentiegenerator, merge)
•    datawarehousing features
•    verfijning van bestaande features




                                                                        4
terminologie


•  relationeel model   •  SQL

   –    schema           –    schema
   –    relatie          –    tabel
   –    tupel            –    rij
   –    attribuut        –    kolom




                                       5
schema

•  bevat
   –  schema-naam
   –  eigenaar en
   –  beschrijving van elementen
      •    tabellen
      •    restricties (constraints)
      •    views
      •    domeinen
      •    autorisaties
      •    …

•  creatie van schema: CREATE SCHEMA

                   CREATE SCHEMA COMPANY 
                         AUTHORIZATION Jsmith ;
                                                   6
cataloog

•    = een verzameling gegevensbankschema's in een “SQL omgeving”
•    de cataloog bevat één speciaal schema: INFORMATION_SCHEMA
•    integriteitsrestricties kunnen opgelegd worden tussen relaties in cataloog
•    schema’s binnen eenzelfde cataloog kunnen elementen delen




                                                                           7
creatie van een tabel

CREATE TABLE  [ <schema name >. ] <table name> 

     ( { <column name> <column type> [<aAribute constraint>] }  

      {<table constraint>} *) 
•  naam
•  voor alle attributen:
    –  naam + SQL-gegevenstype + restricties
•  restricties




                                                                   8
numerieke gegevenstypes en domeinen
 •  gehele waarden:
    –  INTEGER - INT
    –  SMALLINT
 •  niet gehele waarden:
    –  FLOAT – REAL
    –  DOUBLE PRECISION
 •  geformateerde getallen:
    –  DECIMAL (i, j) – DEC (i, j) – NUMERIC (i, j) met
        i: precisie (= totaal aantal dec.cijfers)
        j: schaal (= aantal cijfers na dec. punt)




                                                          10
karakter strings
•  string met vaste lengte:
   –  CHAR (n) – CHARACTER (n)
•  string met variabele lengte:
   –  VARCHAR(n) – CHAR VARYING (n) – CHARACTER VARYING (n)
•  notatie van waarden: tussen apostrofs: ‘abc‘




                                                        11
gegevenstypes en domeinen in SQL

•  bit strings:
   –  met vaste lengte: BIT (n)
   –  met variabele lengte: BIT VARYING (n)
   –  notatie van waarden: B’10101’
•  logische waarden
   –  BOOLEAN
   –  mogelijke waarden:      TRUE    FALSE UNKNOWN




                                                      12
datum en tijd

•  DATE
  –  10 posities: YYYY-MM-DD
  –  DATE’2004-02-23’
•  TIME
  –  ten minste 8 posities: HH:MM:SS
  –  TIME’09:12:47’
•  TIMESTAMP
  –  DATE en TIME en 6 posities voor fracties van seconden:
  –  TIMESTAMP’2004-02-23 09:12:47 648302’




                                                              13
in verschillende implementaties

•  namen kunnen verschillen
•  soms nog meer variaties in types

•  voorbeeld:
   –  http://en.wikipedia.org/wiki/
      Comparison_of_relational_database_management_systems




                                                             14
definitie van type van een attribuut

•  ofwel rechtstreeks
•  ofwel via definitie van domein


            CREATE DOMAIN  SSN_TYPE AS CHAR(9) ;




                                                    15
definiëren van restricties op tabel
•  Soorten:
   –  primaire sleutel:       PRIMARY KEY <attrlist>
   –  alternatieve sleutel:   UNIQUE <attrlist>
   –  verwijssleutel:         FOREIGN KEY <attrlist> REFERENCES
                                             <table><attrlist>
•  Actie bij schending van referentiële integriteit:
   –  bij trigger:            ON DELETE / ON UPDATE
   –  actie:                  SET NULL / CASCADE / SET DEFAULT




                                                           16
restricties op attribuut
•  NOT NULL (automatisch voor primaire sleutels)
•  DEFAULT <value>
•  CHECK (voorwaarde)
   –  kan ook samen met domein declaratie



Dnumber INT NOT NULL CHECK (Dnumber > 0 AND Dnumber < 
21); 




                                                     18
specificeren van restricties

•  twee mogelijkheden
   –  onmiddellijk bij tabel of attribuut
   –  met sleutelwoord ‘CONSTRAINT’ en het geven van een naam
      •  geeft de mogelijkheid om de restrictie later gemakkelijk aan te passen, weg
         te laten,….




                                                                                  19
weglaten van tabel / schema

•  Drop behaviour voor schema:
   –  CASCADE:
      •  schema + alle tabellen erin weglaten
   –  RESTRICT:
      •  schema enkel weglaten als het leeg is

•  Drop behaviour voor tabel:
   –  CASCADE:
      •  alle restricties en views die aan de tabel refereren worden mee weggelaten
   –  RESTRICT:
      •  tabel enkel weglaten als er geen restricties of views naar verwijzen



   DROP SCHEMA  <name> <drop behaviour> 
   DROP TABLE      <name> <drop behaviour> 
                                                                                 21
wijzigen van tabel

ALTER TABLE <name>  
        {   ADD      <column name> <column type> 
           | DROP   <column name> <drop behaviour> 
           | ALTER  <column name> <default opVon> 
           | ADD  CONSTRAINT    <constraint definiVon> 
           | DROP  CONSTRAINT  <constraint name>  <drop 
behaviour> }
                    –  <drop behaviour> =
                        •  CASCADE | RESTRICT
                    –  <default option> =
                        •  DROP DEFAULT | SET DEFAULT <value>




                                                                22
ALTER TABLE  COMPANY.EMPLOYEE 
      ADD COLUMN Job VARCHAR(12) ;

ALTER TABLE  COMPANY.EMPLOYEE 
      DROP COLUMN Address CASCADE ;

     ALTER TABLE  COMPANY.DEPARTMENT 
           ALTER COLUMN Mgr_ssn DROP DEFAULT ;

 ALTER TABLE  COMPANY.DEPARTMENT 
       ALTER COLUMN Mgr_ssn SET DEFAULT ‘33445555’ ;

    ALTER TABLE  COMPANY.EMPLOYEE 
          DROP CONSTRAINT EMPSUPERFK CASCADE ;
                                                        23
opvragingen (queries) in SQL

•  Basisvorm van een vraag (query):

            SELECT <aAributen lijst>  
                 FROM     <tabellen lijst> 
                 WHERE  <condiVes> ;


•  vgl. met relationele algebra:
   –  SELECT          projectie
   –  FROM            carthesisch product
   –  WHERE           selectie



                                              24
voorbeeld

•  Q_0: geef de geboortedatum en het adres van
   werknemer John B. Smith


   SELECT        Bdate, Address 
   FROM          EMPLOYEE 
   WHERE         Fname='John' AND Minit='B' AND Lname='Smith’ ;

  Bdate                Address
  ----------            ------------------------
  1965-01-09            731 Fondren, Houston, TX

   In relaVonele algebra:  
   πBdate,Address (σ Fname = 'John'  AND  Minit = ‘John’  AND  Lname = 
   ‘Smith’ (EMPLOYEE) ) 
•  Q1B: geef naam en adres van alle werknemers die voor
   het "research" departement werken

    SELECT       E.Fname, E.Lname, E.Address 
    FROM         EMPLOYEE  E, DEPARTMENT  D 
    WHERE        D.Dname = 'Research' AND D.Dnumber = E.Dno ;


      •  vergelijk met uitdrukking in tupel relationele calculus


    { t.Fname, t.Lname, t.Address | EMPLOYEE(t)  
                                    AND (∃d) (DEPARTMENT(d)  
                                          AND d.Dname = 'Research’ 
                                          AND d.Number = t.Dno) } 

                                                                      26
 geef namen van projecten die gecontroleerd worden door 
 departement 5 




                                            select  ? 
                                            from   ? 
                                            where ? 




                                                           27
 SELECT pname FROM project WHERE dnum=5; 


 geef social security numbers van werknemers die werken aan 
 projecten die gecontroleerd worden door departement 5 




                                            select  ? 
                                            from   ? 
                                            where ? 

                                                               28
 SELECT pname, essn FROM project, works_on 
 WHERE dnum=5 and pno=pnumber; 

 geef voornaam en familienaam van werknemers die werken aan 
 projecten die gecontroleerd worden door departement 5 




                                           select  ? 
                                           from   ? 
                                           where ? 


                                                          29
SELECT pname 
FROM project 
WHERE dnum=5; 

SELECT pname, essn 
FROM project, works_on 
WHERE dnum=5 and pno=pnumber; 

SELECT pname, fname, lname  
FROM project, works_on, employee  
WHERE dnum=5 and pno=pnumber and essn=ssn; 

                                              30
voorbeeld
•  geef voor elk project dat als locatie Stafford heeft, het
   projectnummer, nummer van het departement dat het leidt, en de
   familienaam, adres en geboortedatum van de manager van dat
   departement


          SELECT      Pnumber, Dnum, Lname, Address, Bdate 
          FROM        PROJECT, DEPARTMENT, EMPLOYEE 
          WHERE       Dnum = Dnumber  AND  Mgr_ssn = Ssn 
                      AND  PlocaVon = 'Stafford’ ; 

    Pnumber Dnum        Lname               Address
    Bdate
    ------- ----
    resultaat:         -------     -----------------------
    ----------
       10      4       Wallace     291 Berry, Bellaire, TX
    1941-06-20
       30      4       Wallace     291 Berry, Bellaire, TX
    1941-06-20
dubbelzinnige attribuutnamen

•  Tot nog toe: steeds duidelijk bij welke relatie een
   attribuut behoorde
•  Wat indien dit niet het geval is?
   vb. attributen Name en Dnumber (i.p.v. Dno) in EMPLOYEE en
     DEPARTMENT tabel


•  Oplossing: attribuutnaam = <tabel>.<attribuut>



  SELECT      Fname, EMPLOYEE.Name, Address 
  FROM        EMPLOYEE, DEPARTMENT 
  WHERE       DEPARTMENT.Name = 'Research' 
              AND DEPARTMENT.Dnumber = EMPLOYEE.Dnumber ;
aliasen

•  voorbeeld:
   –  geef voor elke werknemer de voor- en familienaam en de
      familienaam van zijn/haar supervisor
   –  2 verwijzingen naar EMPLOYEE: een voor werknemer zelf, een
      voor supervisor


•  hoe van elkaar onderscheiden?
•  "aliases": de verwijzingen krijgen aparte namen

       SELECT     E.Fname,  E.Lname, S.Fname, S.Lname 
       FROM       EMPLOYEE  AS E,   EMPLOYEE AS S 
       WHERE      E.Super_ssn = S.Ssn ;

                                                              33
aliasen
–  Q 8: for each employee, retrieve the employee’s first and last
   name and the last name of his or her immediate supervisor

       SELECT       E.Fname,  E.Lname, S.Fname, S.Lname 
       FROM         EMPLOYEE  AS E,   EMPLOYEE AS S 
       WHERE        E.Super_ssn = S.Ssn ;


    SELECT        E.Fname,  E.Lname, S.Fname, S.Lname 
    FROM          EMPLOYEE  E  S 
    WHERE         E.Super_ssn = S.Ssn ; 


–  Definitie: - onmiddellijk na de naam van de relatie
              - na sleutelwoord AS

                                                                    34
weglaten van WHERE en van attributenlijst

•  WHERE kan weggelaten worden: geen selectie

    SELECT     Ssn 
    FROM       EMPLOYEE ;


    SELECT     Ssn, Dname 
    FROM       EMPLOYEE, DEPARTMENT ;
   carthesisch product




                                                        35
weglaten van WHERE en van attributenlijst

•  Alle attributen selecteren (met *) : geen projectie


      SELECT      * 
      FROM        EMPLOYEE 
      WHERE     Dno = 5 ;


       SELECT     * 
       FROM       EMPLOYEE, DEPARTMENT 
       WHERE      Dname = 'Research' AND Dno = Dnumber ;


      SELECT      * 
      FROM        EMPLOYEE, DEPARTMENT ;


                                                            36
Verschil tussen tabellen en relaties

•  een relatie uit het relationeel model is een verzameling
   tupels en bevat dus geen dubbels
•  SQL elimineert niet automatisch dubbels




                                                              37
SELECT      Salary        •  Vermijden van dubbels:
FROM        EMPLOYEE ;
                             SELECT DISTINCT
equivalent met
 SELECT   ALL Salary         SELECT   DISTINCT Salary 
 FROM       EMPLOYEE ;
      FROM       EMPLOYEE ;


          Salary                  Salary
          ------                  ------
          30000                   30000
          40000                   40000
          25000                   25000
          43000                   43000
          38000                   38000
          25000                   55000
          25000
          55000
                                         38
Verzameling-bewerkingen in SQL
–  UNION, INTERSECT, EXCEPT (= verschil)
–  relaties moeten vergelijkbaar zijn
    •  zelfde attribuuttypes in zelfde volgorde
–  dubbels worden automatisch verwijderd

–  vb: Q 4:
    •  geef alle projecten waarbij Smith betrokken is als manager van het
       controlerend departement of waaraan hij meewerkt

(SELECT        DISTINCT Pnumber 
 FROM          PROJECT, DEPARTMENT, EMPLOYEE 
 WHERE         Dnum = Dnumber AND Mgr_ssn = Ssn AND Lname = 'Smith')  

UNION 

(SELECT        DISTINCT Pnumber 
 FROM          PROJECT, WORKS_ON, EMPLOYEE 
 WHERE         Pno = Pnumber AND Essn = Ssn AND Lname = 'Smith') ;
operaties die slaan op multisets

•  sleutelwoord ALL na de operator:
   –  UNION ALL
   –  EXCEPT ALL
   –  INTERSECT ALL

 R  A     S  A        T  A        V  A     W  A 
    a1       a1          a1          a2       a1 
    a2       a2          a1          a3       a2 
    a2       a4          a2 
    a3       a5          a2 
                         a2    T ← R UNION ALL S
                         a3 
                         a4    V ← R EXCEPT ALL S
                         a5 
                               W ← R INTERSECT ALL S
string- en rekenkundige operatoren
•  Test string op patroon: LIKE
    –  _ : één willekeurig teken
    –  % : willekeurige rij tekens


Q12: Geef de naam van alle werknemers die in Houston, Texas wonen
   SELECT       Fname,Lname 
   FROM         EMPLOYEE 
   WHERE        Address LIKE  '%Houston,TX%’ ; 

Q12A: Geef de naam van alle werknemers die in de jaren 1950
geboren zijn
    SELECT        Fname,Lname 
    FROM          EMPLOYEE 
    WHERE         Bdate LIKE  '_ _5_ _ _ _ _ _ _’ ;
rekenkundige operatoren: +, -, *, /

•  kunnen gebruikt worden op numerieke waarden

•  Q13: Geef het salaris van elke werknemer die werkt
   aan project ‘ProductX’, verhoogd met 10 %




     SELECT      Fname, Lname,  1.1 * Salary AS Increased_sal 
     FROM        EMPLOYEE,  WORKS_ON,  PROJECT 
     WHERE       Ssn = Essn  AND  Pno = Pnumber  
                 AND  Pname = 'ProductX’ ;



                                                                 42
andere operatoren
•  strings
   –  concatenatie       ||
•  datum, tijd, tijdsstempel:
   –  verhogen of verlagen met een interval
   –  verschil tussen data, tijden: → een interval
•  BETWEEN:
   –  Q14: Geef alle werknemers van departement 5 met een
      salaris tussen 30 000 en 40 000 EUR

   SELECT       * 
   FROM         EMPLOYEE 
   WHERE        (Salary BETWEEN 30 000 AND 40 000) AND  Dno = 5 ;

   de salaris-voorwaarde is equivalent met
   ((Salary >= 30 000) AND (Salary <= 40 000))                       43
ordenen van query resultaten
•  ORDER BY <attributen> [ ASC | DESC ]

    –  Q 15: Geef een lijst van de namen van de werknemers en de namen van de
       projecten waarop zij werken, per departement, en in elk departement
       alfabetisch geordend volgens familienaam, voornaam



   SELECT               Dname,  Fname,  Lname,  Pname 
   FROM                 DEPARTMENT, EMPLOYEE, WORKS_ON, PROJECT 
   WHERE                Dnumber = Dno  AND  Ssn = Essn  
                        AND  Pno = Pnumber  
   ORDER BY             Dname, Lname, Fname ; 

•  default ordening is stijgend (ASC)
•  dalende orde (DESC) moet steeds expliciet vermeld worden:

  ORDER BY                Dname DESC, Lname ASC, Fname ASC
null en 3-waardige logica

•  3 mogelijkheden:
   –  waarde is niet gekend
   –  waarde is onbeschikbaar of niet vrij gegeven
   –  attribuut is niet van toepassing
•  elke null waarde wordt als verschillend aanzien
•  ⇒ SQL gebruikt 3-waardige logica:
   –  TRUE FALSE UNKNOWN




                                                     45
•  nagaan of een waarde null is:
   –  IS NULL
   –  IS NOT NULL




•  Q 18 : retrieve the names of all employees who have no
   supervisors


             SELECT     Fname, Lname 
             FROM       EMPLOYEE 
             WHERE      Super_ssn IS NULL ;


                                                        46
geneste queries

•  geneste queries
   –  sommige queries vereisen ophalen van bestaande waarden en
      het gebruik ervan in voorwaarden;
   –  dat kan dikwijls op eenvoudige wijze geformuleerd worden met
      geneste queries.
•  IN operator in conditie :
   –  test of tupel ∈ verzameling
   –  verzameling kan zelf door SQL-query bekomen zijn
       •  → geneste queries




                                                                 47
voorbeeld

  –  Q 4A: geef alle projecten waarbij Smith betrokken is als
     manager van het controlerend departement of waaraan hij
     meewerkt

 SELECT  DISTINCT Pnumber 
 FROM                   PROJECT 
 WHERE                  Pnumber IN  
                        (SELECT    Pnumber 
                       FROM        PROJECT, DEPARTMENT, EMPLOYEE 
                          WHERE   Dnum = Dnumber AND Mgr_ssn = Ssn 
                                   AND Lname = 'Smith') 
       OR 
                        Pnumber IN  
                        (SELECT    Pno 
                         FROM      WORKS_ON, EMPLOYEE 
                         WHERE   Essn = Ssn AND Lname = 'Smith') ; 

                                                                      48
IN operator met tupel i.p.v.
enkelvoudige waarde
•  tupel moet vergelijkbaar zijn met een element van de
   verzameling
•  vb:
   –  selecteer de ssn’s van alle werknemers die met dezelfde
      combinatie (project, aantal uren) werken op om het even welk
      project waarop de werknemer ssn = ‘123456789’ werkt

    SELECT     DISTINCT Essn 
    FROM                   WORKS_ON 
    WHERE                  (Pno, Hours) IN  (SELECT   Pno, Hours 
                                               FROM          WORKS_ON 
                                               WHERE     Ssn = '123456789') ; 



                                                                                 49
•  geef de naam van elke werknemer die een persoon ten
   laste heeft met dezelfde voornaam en hetzelfde
   geslacht als de werknemer
    SELECT       E.Fname,  E.Lname 
    FROM         EMPLOYEE  AS  E 
    WHERE        E.Ssn IN (SELECT ESSN 
                             FROM   DEPENDENT  AS  D  
                             WHERE D.Essn   AND   E.Sex = D.Sex 
                             AND   E.Fname = D.Dependent_name) ; 

  Kan dit ook zonder geneste query?

     SELECT       E.Fname,  E.Lname 
     FROM         EMPLOYEE  AS  E , DEPENDENT  AS  D 
     WHERE        E.Ssn = D.Essn   AND   E.Sex = D.Sex 
                  AND   E.Fname = D.Dependent_name ; 
andere vergelijkingsoperatoren
•  >, >=, <, <=, <>
•  combinatie met ANY (of SOME)
   –  v > ANY s : er bestaat een element e van s waarvoor v > e
   –  = ANY is equivalent met IN
•  combinatie met ALL
   –  v > ALL s : voor alle elementen e van s geldt v >e




                                                                  51
voorbeeld

•  bepaal de namen van alle werknemers waarvan het
   salaris groter is dan de salarissen van alle werknemers
   van departement 5


     SELECT                 Lname, Fname 
     FROM                   EMPLOYEE 
     WHERE                  Salary > ALL  (SELECT    Salary 
                                                FROM        EMPLOYEE 
                                                WHERE       Dno = 5) ; 




                                                                          52
oplossen van dubbelzinnigheid in
geneste queries
•  verscheidene niveaus van innesteling zijn mogelijk

•  indien attributen met dezelfde naam voorkomen in
   buitenste en binnenste query:
   –  een referentie verwijst dan naar de binnenste geneste query
   –  om naar een andere relatie te verwijzen moet de attribuutnaam
      gekwalificeerd worden


   SELECT                 E.Fname,  E.Lname 
   FROM                   EMPLOYEE  AS  E 
   WHERE                  E.Ssn  IN ( SELECT  Essn 
                                        FROM     DEPENDENT 
                                        WHERE  Sex = E.Sex 
                                              AND  E.Fname = Dependent_name) ;
                                                                                  53
VRAGEN?



Katrien.verbert@cs.kuleuven.be




                                 54

Weitere ähnliche Inhalte

Mehr von Katrien Verbert

Human-centered AI: how can we support end-users to interact with AI?
Human-centered AI: how can we support end-users to interact with AI?Human-centered AI: how can we support end-users to interact with AI?
Human-centered AI: how can we support end-users to interact with AI?Katrien Verbert
 
Human-centered AI: how can we support end-users to interact with AI?
Human-centered AI: how can we support end-users to interact with AI?Human-centered AI: how can we support end-users to interact with AI?
Human-centered AI: how can we support end-users to interact with AI?Katrien Verbert
 
Human-centered AI: how can we support lay users to understand AI?
Human-centered AI: how can we support lay users to understand AI?Human-centered AI: how can we support lay users to understand AI?
Human-centered AI: how can we support lay users to understand AI?Katrien Verbert
 
Explaining job recommendations: a human-centred perspective
Explaining job recommendations: a human-centred perspectiveExplaining job recommendations: a human-centred perspective
Explaining job recommendations: a human-centred perspectiveKatrien Verbert
 
Explaining recommendations: design implications and lessons learned
Explaining recommendations: design implications and lessons learnedExplaining recommendations: design implications and lessons learned
Explaining recommendations: design implications and lessons learnedKatrien Verbert
 
Designing Learning Analytics Dashboards: Lessons Learned
Designing Learning Analytics Dashboards: Lessons LearnedDesigning Learning Analytics Dashboards: Lessons Learned
Designing Learning Analytics Dashboards: Lessons LearnedKatrien Verbert
 
Human-centered AI: towards the next generation of interactive and adaptive ex...
Human-centered AI: towards the next generation of interactive and adaptive ex...Human-centered AI: towards the next generation of interactive and adaptive ex...
Human-centered AI: towards the next generation of interactive and adaptive ex...Katrien Verbert
 
Explainable AI for non-expert users
Explainable AI for non-expert usersExplainable AI for non-expert users
Explainable AI for non-expert usersKatrien Verbert
 
Towards the next generation of interactive and adaptive explanation methods
Towards the next generation of interactive and adaptive explanation methodsTowards the next generation of interactive and adaptive explanation methods
Towards the next generation of interactive and adaptive explanation methodsKatrien Verbert
 
Personalized food recommendations: combining recommendation, visualization an...
Personalized food recommendations: combining recommendation, visualization an...Personalized food recommendations: combining recommendation, visualization an...
Personalized food recommendations: combining recommendation, visualization an...Katrien Verbert
 
Explaining and Exploring Job Recommendations: a User-driven Approach for Inte...
Explaining and Exploring Job Recommendations: a User-driven Approach for Inte...Explaining and Exploring Job Recommendations: a User-driven Approach for Inte...
Explaining and Exploring Job Recommendations: a User-driven Approach for Inte...Katrien Verbert
 
Learning analytics for feedback at scale
Learning analytics for feedback at scaleLearning analytics for feedback at scale
Learning analytics for feedback at scaleKatrien Verbert
 
Interactive recommender systems and dashboards for learning
Interactive recommender systems and dashboards for learningInteractive recommender systems and dashboards for learning
Interactive recommender systems and dashboards for learningKatrien Verbert
 
Interactive recommender systems: opening up the “black box”
Interactive recommender systems: opening up the “black box”Interactive recommender systems: opening up the “black box”
Interactive recommender systems: opening up the “black box”Katrien Verbert
 
Interactive Recommender Systems
Interactive Recommender SystemsInteractive Recommender Systems
Interactive Recommender SystemsKatrien Verbert
 
Web Information Systems Lecture 2: HTML
Web Information Systems Lecture 2: HTMLWeb Information Systems Lecture 2: HTML
Web Information Systems Lecture 2: HTMLKatrien Verbert
 
Information Visualisation: perception and principles
Information Visualisation: perception and principlesInformation Visualisation: perception and principles
Information Visualisation: perception and principlesKatrien Verbert
 
Web Information Systems Lecture 1: Introduction
Web Information Systems Lecture 1: IntroductionWeb Information Systems Lecture 1: Introduction
Web Information Systems Lecture 1: IntroductionKatrien Verbert
 
Information Visualisation: Introduction
Information Visualisation: IntroductionInformation Visualisation: Introduction
Information Visualisation: IntroductionKatrien Verbert
 

Mehr von Katrien Verbert (20)

Explainability methods
Explainability methodsExplainability methods
Explainability methods
 
Human-centered AI: how can we support end-users to interact with AI?
Human-centered AI: how can we support end-users to interact with AI?Human-centered AI: how can we support end-users to interact with AI?
Human-centered AI: how can we support end-users to interact with AI?
 
Human-centered AI: how can we support end-users to interact with AI?
Human-centered AI: how can we support end-users to interact with AI?Human-centered AI: how can we support end-users to interact with AI?
Human-centered AI: how can we support end-users to interact with AI?
 
Human-centered AI: how can we support lay users to understand AI?
Human-centered AI: how can we support lay users to understand AI?Human-centered AI: how can we support lay users to understand AI?
Human-centered AI: how can we support lay users to understand AI?
 
Explaining job recommendations: a human-centred perspective
Explaining job recommendations: a human-centred perspectiveExplaining job recommendations: a human-centred perspective
Explaining job recommendations: a human-centred perspective
 
Explaining recommendations: design implications and lessons learned
Explaining recommendations: design implications and lessons learnedExplaining recommendations: design implications and lessons learned
Explaining recommendations: design implications and lessons learned
 
Designing Learning Analytics Dashboards: Lessons Learned
Designing Learning Analytics Dashboards: Lessons LearnedDesigning Learning Analytics Dashboards: Lessons Learned
Designing Learning Analytics Dashboards: Lessons Learned
 
Human-centered AI: towards the next generation of interactive and adaptive ex...
Human-centered AI: towards the next generation of interactive and adaptive ex...Human-centered AI: towards the next generation of interactive and adaptive ex...
Human-centered AI: towards the next generation of interactive and adaptive ex...
 
Explainable AI for non-expert users
Explainable AI for non-expert usersExplainable AI for non-expert users
Explainable AI for non-expert users
 
Towards the next generation of interactive and adaptive explanation methods
Towards the next generation of interactive and adaptive explanation methodsTowards the next generation of interactive and adaptive explanation methods
Towards the next generation of interactive and adaptive explanation methods
 
Personalized food recommendations: combining recommendation, visualization an...
Personalized food recommendations: combining recommendation, visualization an...Personalized food recommendations: combining recommendation, visualization an...
Personalized food recommendations: combining recommendation, visualization an...
 
Explaining and Exploring Job Recommendations: a User-driven Approach for Inte...
Explaining and Exploring Job Recommendations: a User-driven Approach for Inte...Explaining and Exploring Job Recommendations: a User-driven Approach for Inte...
Explaining and Exploring Job Recommendations: a User-driven Approach for Inte...
 
Learning analytics for feedback at scale
Learning analytics for feedback at scaleLearning analytics for feedback at scale
Learning analytics for feedback at scale
 
Interactive recommender systems and dashboards for learning
Interactive recommender systems and dashboards for learningInteractive recommender systems and dashboards for learning
Interactive recommender systems and dashboards for learning
 
Interactive recommender systems: opening up the “black box”
Interactive recommender systems: opening up the “black box”Interactive recommender systems: opening up the “black box”
Interactive recommender systems: opening up the “black box”
 
Interactive Recommender Systems
Interactive Recommender SystemsInteractive Recommender Systems
Interactive Recommender Systems
 
Web Information Systems Lecture 2: HTML
Web Information Systems Lecture 2: HTMLWeb Information Systems Lecture 2: HTML
Web Information Systems Lecture 2: HTML
 
Information Visualisation: perception and principles
Information Visualisation: perception and principlesInformation Visualisation: perception and principles
Information Visualisation: perception and principles
 
Web Information Systems Lecture 1: Introduction
Web Information Systems Lecture 1: IntroductionWeb Information Systems Lecture 1: Introduction
Web Information Systems Lecture 1: Introduction
 
Information Visualisation: Introduction
Information Visualisation: IntroductionInformation Visualisation: Introduction
Information Visualisation: Introduction
 

SQL

  • 1. SQL – deel 1 Katrien Verbert en Joris Klerkx katrien.verbert@cs.kuleuven.be joris.klerkx@cs.kuleuven.be
  • 2. geschiedenis •  SEQUEL (Structured English Query Language) –  voor experimentele gegevensbank "System R" (IBM) •  → SQL (Structured Query Language) –  voor DB2, Oracle, INGRES/SQL, ... –  eerste commerciële versie: Oracle in 1979 2
  • 3. standaardisatie: ANSI - ISO •  SQL1 : 1986 •  SQL2 of SQL92 : 1992 –  “levels of conformance”: entry – intemediate - full •  SQL99 : 1999 –  aanvullingen met o.a. nieuwe data types, object-georiënteerde concepten en triggers –  levels of conformance: Core SQL:1999 - Enhanced SQL:1999 de meeste implementaties van SQL verschillen in meer of mindere mate van de standaard 3
  • 4. SQL 2003 •  ongeveer zelfde Core als SQL99 •  nieuwe object-relationele features (multiset, array types, etc.) •  XML-gerelateerde features (SQL/XML) •  meer functies (sequentiegenerator, merge) •  datawarehousing features •  verfijning van bestaande features 4
  • 5. terminologie •  relationeel model •  SQL –  schema –  schema –  relatie –  tabel –  tupel –  rij –  attribuut –  kolom 5
  • 6. schema •  bevat –  schema-naam –  eigenaar en –  beschrijving van elementen •  tabellen •  restricties (constraints) •  views •  domeinen •  autorisaties •  … •  creatie van schema: CREATE SCHEMA CREATE SCHEMA COMPANY   AUTHORIZATION Jsmith ; 6
  • 7. cataloog •  = een verzameling gegevensbankschema's in een “SQL omgeving” •  de cataloog bevat één speciaal schema: INFORMATION_SCHEMA •  integriteitsrestricties kunnen opgelegd worden tussen relaties in cataloog •  schema’s binnen eenzelfde cataloog kunnen elementen delen 7
  • 8. creatie van een tabel CREATE TABLE  [ <schema name >. ] <table name>       ( { <column name> <column type> [<aAribute constraint>] }         {<table constraint>} *)  •  naam •  voor alle attributen: –  naam + SQL-gegevenstype + restricties •  restricties 8
  • 9.
  • 10. numerieke gegevenstypes en domeinen •  gehele waarden: –  INTEGER - INT –  SMALLINT •  niet gehele waarden: –  FLOAT – REAL –  DOUBLE PRECISION •  geformateerde getallen: –  DECIMAL (i, j) – DEC (i, j) – NUMERIC (i, j) met i: precisie (= totaal aantal dec.cijfers) j: schaal (= aantal cijfers na dec. punt) 10
  • 11. karakter strings •  string met vaste lengte: –  CHAR (n) – CHARACTER (n) •  string met variabele lengte: –  VARCHAR(n) – CHAR VARYING (n) – CHARACTER VARYING (n) •  notatie van waarden: tussen apostrofs: ‘abc‘ 11
  • 12. gegevenstypes en domeinen in SQL •  bit strings: –  met vaste lengte: BIT (n) –  met variabele lengte: BIT VARYING (n) –  notatie van waarden: B’10101’ •  logische waarden –  BOOLEAN –  mogelijke waarden: TRUE FALSE UNKNOWN 12
  • 13. datum en tijd •  DATE –  10 posities: YYYY-MM-DD –  DATE’2004-02-23’ •  TIME –  ten minste 8 posities: HH:MM:SS –  TIME’09:12:47’ •  TIMESTAMP –  DATE en TIME en 6 posities voor fracties van seconden: –  TIMESTAMP’2004-02-23 09:12:47 648302’ 13
  • 14. in verschillende implementaties •  namen kunnen verschillen •  soms nog meer variaties in types •  voorbeeld: –  http://en.wikipedia.org/wiki/ Comparison_of_relational_database_management_systems 14
  • 15. definitie van type van een attribuut •  ofwel rechtstreeks •  ofwel via definitie van domein CREATE DOMAIN  SSN_TYPE AS CHAR(9) ; 15
  • 16. definiëren van restricties op tabel •  Soorten: –  primaire sleutel: PRIMARY KEY <attrlist> –  alternatieve sleutel: UNIQUE <attrlist> –  verwijssleutel: FOREIGN KEY <attrlist> REFERENCES <table><attrlist> •  Actie bij schending van referentiële integriteit: –  bij trigger: ON DELETE / ON UPDATE –  actie: SET NULL / CASCADE / SET DEFAULT 16
  • 17.
  • 18. restricties op attribuut •  NOT NULL (automatisch voor primaire sleutels) •  DEFAULT <value> •  CHECK (voorwaarde) –  kan ook samen met domein declaratie Dnumber INT NOT NULL CHECK (Dnumber > 0 AND Dnumber <  21);  18
  • 19. specificeren van restricties •  twee mogelijkheden –  onmiddellijk bij tabel of attribuut –  met sleutelwoord ‘CONSTRAINT’ en het geven van een naam •  geeft de mogelijkheid om de restrictie later gemakkelijk aan te passen, weg te laten,…. 19
  • 20.
  • 21. weglaten van tabel / schema •  Drop behaviour voor schema: –  CASCADE: •  schema + alle tabellen erin weglaten –  RESTRICT: •  schema enkel weglaten als het leeg is •  Drop behaviour voor tabel: –  CASCADE: •  alle restricties en views die aan de tabel refereren worden mee weggelaten –  RESTRICT: •  tabel enkel weglaten als er geen restricties of views naar verwijzen DROP SCHEMA  <name> <drop behaviour>  DROP TABLE      <name> <drop behaviour>  21
  • 22. wijzigen van tabel ALTER TABLE <name>           {   ADD      <column name> <column type>    | DROP   <column name> <drop behaviour>    | ALTER  <column name> <default opVon>    | ADD  CONSTRAINT    <constraint definiVon>    | DROP  CONSTRAINT  <constraint name>  <drop  behaviour> } –  <drop behaviour> = •  CASCADE | RESTRICT –  <default option> = •  DROP DEFAULT | SET DEFAULT <value> 22
  • 23. ALTER TABLE  COMPANY.EMPLOYEE   ADD COLUMN Job VARCHAR(12) ; ALTER TABLE  COMPANY.EMPLOYEE   DROP COLUMN Address CASCADE ; ALTER TABLE  COMPANY.DEPARTMENT   ALTER COLUMN Mgr_ssn DROP DEFAULT ; ALTER TABLE  COMPANY.DEPARTMENT   ALTER COLUMN Mgr_ssn SET DEFAULT ‘33445555’ ; ALTER TABLE  COMPANY.EMPLOYEE   DROP CONSTRAINT EMPSUPERFK CASCADE ; 23
  • 24. opvragingen (queries) in SQL •  Basisvorm van een vraag (query): SELECT <aAributen lijst>        FROM     <tabellen lijst>       WHERE  <condiVes> ; •  vgl. met relationele algebra: –  SELECT projectie –  FROM carthesisch product –  WHERE selectie 24
  • 25. voorbeeld •  Q_0: geef de geboortedatum en het adres van werknemer John B. Smith SELECT   Bdate, Address  FROM       EMPLOYEE  WHERE   Fname='John' AND Minit='B' AND Lname='Smith’ ; Bdate Address ---------- ------------------------ 1965-01-09 731 Fondren, Houston, TX In relaVonele algebra:   πBdate,Address (σ Fname = 'John'  AND  Minit = ‘John’  AND  Lname =  ‘Smith’ (EMPLOYEE) ) 
  • 26. •  Q1B: geef naam en adres van alle werknemers die voor het "research" departement werken SELECT   E.Fname, E.Lname, E.Address  FROM   EMPLOYEE  E, DEPARTMENT  D  WHERE   D.Dname = 'Research' AND D.Dnumber = E.Dno ; •  vergelijk met uitdrukking in tupel relationele calculus { t.Fname, t.Lname, t.Address | EMPLOYEE(t)                       AND (∃d) (DEPARTMENT(d)                                     AND d.Dname = 'Research’                                    AND d.Number = t.Dno) }  26
  • 31. voorbeeld •  geef voor elk project dat als locatie Stafford heeft, het projectnummer, nummer van het departement dat het leidt, en de familienaam, adres en geboortedatum van de manager van dat departement SELECT   Pnumber, Dnum, Lname, Address, Bdate  FROM   PROJECT, DEPARTMENT, EMPLOYEE  WHERE   Dnum = Dnumber  AND  Mgr_ssn = Ssn            AND  PlocaVon = 'Stafford’ ;  Pnumber Dnum Lname Address Bdate ------- ---- resultaat: ------- ----------------------- ---------- 10 4 Wallace 291 Berry, Bellaire, TX 1941-06-20 30 4 Wallace 291 Berry, Bellaire, TX 1941-06-20
  • 32. dubbelzinnige attribuutnamen •  Tot nog toe: steeds duidelijk bij welke relatie een attribuut behoorde •  Wat indien dit niet het geval is? vb. attributen Name en Dnumber (i.p.v. Dno) in EMPLOYEE en DEPARTMENT tabel •  Oplossing: attribuutnaam = <tabel>.<attribuut> SELECT   Fname, EMPLOYEE.Name, Address  FROM   EMPLOYEE, DEPARTMENT  WHERE   DEPARTMENT.Name = 'Research'            AND DEPARTMENT.Dnumber = EMPLOYEE.Dnumber ;
  • 33. aliasen •  voorbeeld: –  geef voor elke werknemer de voor- en familienaam en de familienaam van zijn/haar supervisor –  2 verwijzingen naar EMPLOYEE: een voor werknemer zelf, een voor supervisor •  hoe van elkaar onderscheiden? •  "aliases": de verwijzingen krijgen aparte namen SELECT   E.Fname,  E.Lname, S.Fname, S.Lname  FROM   EMPLOYEE  AS E,   EMPLOYEE AS S  WHERE   E.Super_ssn = S.Ssn ; 33
  • 34. aliasen –  Q 8: for each employee, retrieve the employee’s first and last name and the last name of his or her immediate supervisor SELECT   E.Fname,  E.Lname, S.Fname, S.Lname  FROM   EMPLOYEE  AS E,   EMPLOYEE AS S  WHERE   E.Super_ssn = S.Ssn ; SELECT   E.Fname,  E.Lname, S.Fname, S.Lname  FROM   EMPLOYEE  E  S  WHERE   E.Super_ssn = S.Ssn ;  –  Definitie: - onmiddellijk na de naam van de relatie - na sleutelwoord AS 34
  • 35. weglaten van WHERE en van attributenlijst •  WHERE kan weggelaten worden: geen selectie SELECT   Ssn  FROM   EMPLOYEE ; SELECT   Ssn, Dname  FROM   EMPLOYEE, DEPARTMENT ; carthesisch product 35
  • 36. weglaten van WHERE en van attributenlijst •  Alle attributen selecteren (met *) : geen projectie SELECT   *  FROM   EMPLOYEE  WHERE     Dno = 5 ; SELECT   *  FROM   EMPLOYEE, DEPARTMENT  WHERE   Dname = 'Research' AND Dno = Dnumber ; SELECT   *  FROM   EMPLOYEE, DEPARTMENT ; 36
  • 37. Verschil tussen tabellen en relaties •  een relatie uit het relationeel model is een verzameling tupels en bevat dus geen dubbels •  SQL elimineert niet automatisch dubbels 37
  • 38. SELECT  Salary  •  Vermijden van dubbels: FROM   EMPLOYEE ; SELECT DISTINCT equivalent met SELECT   ALL Salary  SELECT   DISTINCT Salary  FROM       EMPLOYEE ; FROM       EMPLOYEE ; Salary Salary ------ ------ 30000 30000 40000 40000 25000 25000 43000 43000 38000 38000 25000 55000 25000 55000 38
  • 39. Verzameling-bewerkingen in SQL –  UNION, INTERSECT, EXCEPT (= verschil) –  relaties moeten vergelijkbaar zijn •  zelfde attribuuttypes in zelfde volgorde –  dubbels worden automatisch verwijderd –  vb: Q 4: •  geef alle projecten waarbij Smith betrokken is als manager van het controlerend departement of waaraan hij meewerkt (SELECT   DISTINCT Pnumber   FROM   PROJECT, DEPARTMENT, EMPLOYEE   WHERE   Dnum = Dnumber AND Mgr_ssn = Ssn AND Lname = 'Smith')   UNION  (SELECT   DISTINCT Pnumber   FROM   PROJECT, WORKS_ON, EMPLOYEE   WHERE   Pno = Pnumber AND Essn = Ssn AND Lname = 'Smith') ;
  • 40. operaties die slaan op multisets •  sleutelwoord ALL na de operator: –  UNION ALL –  EXCEPT ALL –  INTERSECT ALL R  A  S  A  T  A  V  A  W  A  a1  a1  a1  a2  a1  a2  a2  a1  a3  a2  a2  a4  a2  a3  a5  a2  a2  T ← R UNION ALL S a3  a4  V ← R EXCEPT ALL S a5  W ← R INTERSECT ALL S
  • 41. string- en rekenkundige operatoren •  Test string op patroon: LIKE –  _ : één willekeurig teken –  % : willekeurige rij tekens Q12: Geef de naam van alle werknemers die in Houston, Texas wonen SELECT   Fname,Lname  FROM   EMPLOYEE  WHERE   Address LIKE  '%Houston,TX%’ ;  Q12A: Geef de naam van alle werknemers die in de jaren 1950 geboren zijn SELECT   Fname,Lname  FROM   EMPLOYEE  WHERE   Bdate LIKE  '_ _5_ _ _ _ _ _ _’ ;
  • 42. rekenkundige operatoren: +, -, *, / •  kunnen gebruikt worden op numerieke waarden •  Q13: Geef het salaris van elke werknemer die werkt aan project ‘ProductX’, verhoogd met 10 % SELECT   Fname, Lname,  1.1 * Salary AS Increased_sal  FROM   EMPLOYEE,  WORKS_ON,  PROJECT  WHERE   Ssn = Essn  AND  Pno = Pnumber             AND  Pname = 'ProductX’ ; 42
  • 43. andere operatoren •  strings –  concatenatie || •  datum, tijd, tijdsstempel: –  verhogen of verlagen met een interval –  verschil tussen data, tijden: → een interval •  BETWEEN: –  Q14: Geef alle werknemers van departement 5 met een salaris tussen 30 000 en 40 000 EUR SELECT   *  FROM   EMPLOYEE  WHERE   (Salary BETWEEN 30 000 AND 40 000) AND  Dno = 5 ; de salaris-voorwaarde is equivalent met ((Salary >= 30 000) AND (Salary <= 40 000)) 43
  • 44. ordenen van query resultaten •  ORDER BY <attributen> [ ASC | DESC ] –  Q 15: Geef een lijst van de namen van de werknemers en de namen van de projecten waarop zij werken, per departement, en in elk departement alfabetisch geordend volgens familienaam, voornaam SELECT     Dname,  Fname,  Lname,  Pname  FROM     DEPARTMENT, EMPLOYEE, WORKS_ON, PROJECT  WHERE     Dnumber = Dno  AND  Ssn = Essn        AND  Pno = Pnumber   ORDER BY     Dname, Lname, Fname ;  •  default ordening is stijgend (ASC) •  dalende orde (DESC) moet steeds expliciet vermeld worden: ORDER BY Dname DESC, Lname ASC, Fname ASC
  • 45. null en 3-waardige logica •  3 mogelijkheden: –  waarde is niet gekend –  waarde is onbeschikbaar of niet vrij gegeven –  attribuut is niet van toepassing •  elke null waarde wordt als verschillend aanzien •  ⇒ SQL gebruikt 3-waardige logica: –  TRUE FALSE UNKNOWN 45
  • 46. •  nagaan of een waarde null is: –  IS NULL –  IS NOT NULL •  Q 18 : retrieve the names of all employees who have no supervisors SELECT   Fname, Lname  FROM   EMPLOYEE  WHERE   Super_ssn IS NULL ; 46
  • 47. geneste queries •  geneste queries –  sommige queries vereisen ophalen van bestaande waarden en het gebruik ervan in voorwaarden; –  dat kan dikwijls op eenvoudige wijze geformuleerd worden met geneste queries. •  IN operator in conditie : –  test of tupel ∈ verzameling –  verzameling kan zelf door SQL-query bekomen zijn •  → geneste queries 47
  • 48. voorbeeld –  Q 4A: geef alle projecten waarbij Smith betrokken is als manager van het controlerend departement of waaraan hij meewerkt SELECT  DISTINCT Pnumber  FROM   PROJECT  WHERE   Pnumber IN      (SELECT   Pnumber                        FROM   PROJECT, DEPARTMENT, EMPLOYEE                           WHERE   Dnum = Dnumber AND Mgr_ssn = Ssn                              AND Lname = 'Smith')        OR            Pnumber IN      (SELECT   Pno                          FROM   WORKS_ON, EMPLOYEE                          WHERE   Essn = Ssn AND Lname = 'Smith') ;  48
  • 49. IN operator met tupel i.p.v. enkelvoudige waarde •  tupel moet vergelijkbaar zijn met een element van de verzameling •  vb: –  selecteer de ssn’s van alle werknemers die met dezelfde combinatie (project, aantal uren) werken op om het even welk project waarop de werknemer ssn = ‘123456789’ werkt SELECT     DISTINCT Essn  FROM   WORKS_ON  WHERE   (Pno, Hours) IN  (SELECT   Pno, Hours                               FROM   WORKS_ON                               WHERE     Ssn = '123456789') ;  49
  • 50. •  geef de naam van elke werknemer die een persoon ten laste heeft met dezelfde voornaam en hetzelfde geslacht als de werknemer SELECT   E.Fname,  E.Lname  FROM   EMPLOYEE  AS  E  WHERE   E.Ssn IN (SELECT ESSN            FROM   DEPENDENT  AS  D             WHERE D.Essn   AND   E.Sex = D.Sex                   AND   E.Fname = D.Dependent_name) ;  Kan dit ook zonder geneste query? SELECT   E.Fname,  E.Lname  FROM   EMPLOYEE  AS  E , DEPENDENT  AS  D  WHERE   E.Ssn = D.Essn   AND   E.Sex = D.Sex            AND   E.Fname = D.Dependent_name ; 
  • 51. andere vergelijkingsoperatoren •  >, >=, <, <=, <> •  combinatie met ANY (of SOME) –  v > ANY s : er bestaat een element e van s waarvoor v > e –  = ANY is equivalent met IN •  combinatie met ALL –  v > ALL s : voor alle elementen e van s geldt v >e 51
  • 52. voorbeeld •  bepaal de namen van alle werknemers waarvan het salaris groter is dan de salarissen van alle werknemers van departement 5 SELECT   Lname, Fname  FROM   EMPLOYEE  WHERE   Salary > ALL  (SELECT   Salary                               FROM   EMPLOYEE                               WHERE   Dno = 5) ;  52
  • 53. oplossen van dubbelzinnigheid in geneste queries •  verscheidene niveaus van innesteling zijn mogelijk •  indien attributen met dezelfde naam voorkomen in buitenste en binnenste query: –  een referentie verwijst dan naar de binnenste geneste query –  om naar een andere relatie te verwijzen moet de attribuutnaam gekwalificeerd worden SELECT   E.Fname,  E.Lname  FROM   EMPLOYEE  AS  E  WHERE   E.Ssn  IN ( SELECT  Essn                        FROM     DEPENDENT                        WHERE  Sex = E.Sex                                     AND  E.Fname = Dependent_name) ; 53