From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../Datenbanken 2/Praktikum3/DBII_Praktikum3.pdf | Bin 0 -> 110825 bytes .../Datenbanken 2/Praktikum3/DBII_Praktikum3.zip | Bin 0 -> 108373 bytes Bachelor/Datenbanken 2/Praktikum3/bibcreate.sql | 279 +++++++++++++++++++++ .../Datenbanken 2/Praktikum3/bibcreatemysql.sql | 150 +++++++++++ Bachelor/Datenbanken 2/Praktikum3/bibdrop.sql | 89 +++++++ Bachelor/Datenbanken 2/Praktikum3/bibinsert.sql | 166 ++++++++++++ Bachelor/Datenbanken 2/Praktikum3/selects.sql | 130 ++++++++++ 7 files changed, 814 insertions(+) create mode 100644 Bachelor/Datenbanken 2/Praktikum3/DBII_Praktikum3.pdf create mode 100644 Bachelor/Datenbanken 2/Praktikum3/DBII_Praktikum3.zip create mode 100644 Bachelor/Datenbanken 2/Praktikum3/bibcreate.sql create mode 100644 Bachelor/Datenbanken 2/Praktikum3/bibcreatemysql.sql create mode 100644 Bachelor/Datenbanken 2/Praktikum3/bibdrop.sql create mode 100644 Bachelor/Datenbanken 2/Praktikum3/bibinsert.sql create mode 100644 Bachelor/Datenbanken 2/Praktikum3/selects.sql (limited to 'Bachelor/Datenbanken 2/Praktikum3') diff --git a/Bachelor/Datenbanken 2/Praktikum3/DBII_Praktikum3.pdf b/Bachelor/Datenbanken 2/Praktikum3/DBII_Praktikum3.pdf new file mode 100644 index 0000000..2fe5afe Binary files /dev/null and b/Bachelor/Datenbanken 2/Praktikum3/DBII_Praktikum3.pdf differ diff --git a/Bachelor/Datenbanken 2/Praktikum3/DBII_Praktikum3.zip b/Bachelor/Datenbanken 2/Praktikum3/DBII_Praktikum3.zip new file mode 100644 index 0000000..9a2c053 Binary files /dev/null and b/Bachelor/Datenbanken 2/Praktikum3/DBII_Praktikum3.zip differ diff --git a/Bachelor/Datenbanken 2/Praktikum3/bibcreate.sql b/Bachelor/Datenbanken 2/Praktikum3/bibcreate.sql new file mode 100644 index 0000000..ef2ace1 --- /dev/null +++ b/Bachelor/Datenbanken 2/Praktikum3/bibcreate.sql @@ -0,0 +1,279 @@ +/*==============================================================*/ +/* Database name: CONCEPTUALDATAMODEL_1 */ +/* DBMS name: ORACLE Version 9i */ +/* Created on: 29.03.2006 09:46:49 */ +/*==============================================================*/ + + +alter table AUDIO + drop constraint FK_AUDIO_INHERITAN_LEIHOBJE +/ + + +alter table AUSLEIHE + drop constraint FK_AUSLEIHE_RELATIONS_LEIHOBJE +/ + + +alter table AUSLEIHE + drop constraint FK_AUSLEIHE_RELATIONS_ENTLEIHE +/ + + +alter table AUTOR_BUCH + drop constraint FK_AUTOR_BU_AUTOR_BUC_BUCH +/ + + +alter table AUTOR_BUCH + drop constraint FK_AUTOR_BU_AUTOR_BUC_AUTOR +/ + + +alter table BUCH + drop constraint FK_BUCH_INHERITAN_LEIHOBJE +/ + + +alter table ZEITSCHRIFT + drop constraint FK_ZEITSCHR_INHERITAN_LEIHOBJE +/ + + +drop index RELATIONSHIP_4_FK +/ + + +drop index RELATIONSHIP_5_FK +/ + + +drop index AUTOR_BUCH2_FK +/ + + +drop index AUTOR_BUCH_FK +/ + + +drop table AUDIO cascade constraints +/ + + +drop table AUSLEIHE cascade constraints +/ + + +drop table AUTOR cascade constraints +/ + + +drop table AUTOR_BUCH cascade constraints +/ + + +drop table BUCH cascade constraints +/ + + +drop table ENTLEIHER cascade constraints +/ + + +drop table LEIHOBJEKT cascade constraints +/ + + +drop table ZEITSCHRIFT cascade constraints +/ + + +/*==============================================================*/ +/* Table: AUDIO */ +/*==============================================================*/ + + +create table AUDIO ( + LEIHNR CHAR(10) not null, + KATEGORIE CHAR(2), + ATITEL VARCHAR2(30), + constraint PK_AUDIO primary key (LEIHNR) +) +/ + + +/*==============================================================*/ +/* Table: AUSLEIHE */ +/*==============================================================*/ + + +create table AUSLEIHE ( + LEIHNR CHAR(10) not null, + ENR CHAR(10) not null, + DATUM DATE not null, + BACKDATE DATE, + OVER INTEGER, + constraint PK_AUSLEIHE primary key (LEIHNR, ENR, DATUM) +) +/ + + +/*==============================================================*/ +/* Index: RELATIONSHIP_4_FK */ +/*==============================================================*/ +create index RELATIONSHIP_4_FK on AUSLEIHE ( + LEIHNR ASC +) +/ + + +/*==============================================================*/ +/* Index: RELATIONSHIP_5_FK */ +/*==============================================================*/ +create index RELATIONSHIP_5_FK on AUSLEIHE ( + ENR ASC +) +/ + + +/*==============================================================*/ +/* Table: AUTOR */ +/*==============================================================*/ + + +create table AUTOR ( + ACODE CHAR(7) not null, + ANAME VARCHAR2(20), + constraint PK_AUTOR primary key (ACODE) +) +/ + + +/*==============================================================*/ +/* Table: AUTOR_BUCH */ +/*==============================================================*/ + + +create table AUTOR_BUCH ( + LEIHNR CHAR(10) not null, + ACODE CHAR(7) not null, + constraint PK_AUTOR_BUCH primary key (LEIHNR, ACODE) +) +/ + + +/*==============================================================*/ +/* Index: AUTOR_BUCH_FK */ +/*==============================================================*/ +create index AUTOR_BUCH_FK on AUTOR_BUCH ( + LEIHNR ASC +) +/ + + +/*==============================================================*/ +/* Index: AUTOR_BUCH2_FK */ +/*==============================================================*/ +create index AUTOR_BUCH2_FK on AUTOR_BUCH ( + ACODE ASC +) +/ + + +/*==============================================================*/ +/* Table: BUCH */ +/*==============================================================*/ + + +create table BUCH ( + LEIHNR CHAR(10) not null, + ISBN CHAR(15), + BTITEL VARCHAR2(30), + ERSCHJAHR INTEGER, + constraint PK_BUCH primary key (LEIHNR) +) +/ + + +/*==============================================================*/ +/* Table: ENTLEIHER */ +/*==============================================================*/ + + +create table ENTLEIHER ( + ENR CHAR(10) not null, + ENAME VARCHAR2(20), + constraint PK_ENTLEIHER primary key (ENR) +) +/ + + +/*==============================================================*/ +/* Table: LEIHOBJEKT */ +/*==============================================================*/ + + +create table LEIHOBJEKT ( + LEIHNR CHAR(10) not null, + LEIHTYP CHAR(1) not null, + constraint PK_LEIHOBJEKT primary key (LEIHNR) +) +/ + + +/*==============================================================*/ +/* Table: ZEITSCHRIFT */ +/*==============================================================*/ + + +create table ZEITSCHRIFT ( + LEIHNR CHAR(10) not null, + JAHRGANG INTEGER, + ZTITEL VARCHAR2(30), + constraint PK_ZEITSCHRIFT primary key (LEIHNR) +) +/ + + +alter table AUDIO + add constraint FK_AUDIO_INHERITAN_LEIHOBJE foreign key (LEIHNR) + references LEIHOBJEKT (LEIHNR) +/ + + +alter table AUSLEIHE + add constraint FK_AUSLEIHE_RELATIONS_LEIHOBJE foreign key (LEIHNR) + references LEIHOBJEKT (LEIHNR) +/ + + +alter table AUSLEIHE + add constraint FK_AUSLEIHE_RELATIONS_ENTLEIHE foreign key (ENR) + references ENTLEIHER (ENR) +/ + + +alter table AUTOR_BUCH + add constraint FK_AUTOR_BU_AUTOR_BUC_BUCH foreign key (LEIHNR) + references BUCH (LEIHNR) +/ + + +alter table AUTOR_BUCH + add constraint FK_AUTOR_BU_AUTOR_BUC_AUTOR foreign key (ACODE) + references AUTOR (ACODE) +/ + + +alter table BUCH + add constraint FK_BUCH_INHERITAN_LEIHOBJE foreign key (LEIHNR) + references LEIHOBJEKT (LEIHNR) +/ + + +alter table ZEITSCHRIFT + add constraint FK_ZEITSCHR_INHERITAN_LEIHOBJE foreign key (LEIHNR) + references LEIHOBJEKT (LEIHNR) +/ + + diff --git a/Bachelor/Datenbanken 2/Praktikum3/bibcreatemysql.sql b/Bachelor/Datenbanken 2/Praktikum3/bibcreatemysql.sql new file mode 100644 index 0000000..73f11f5 --- /dev/null +++ b/Bachelor/Datenbanken 2/Praktikum3/bibcreatemysql.sql @@ -0,0 +1,150 @@ +/*==============================================================*/ +/* Database name: CONCEPTUALDATAMODEL_1 */ +/* DBMS name: MySQL 3.23 - noch ohne FK-Constraints! */ +/* Created on: 23.04.2006 20:43:53 */ +/*==============================================================*/ + + +drop index RELATIONSHIP_4_FK on AUSLEIHE; + +drop index RELATIONSHIP_5_FK on AUSLEIHE; + +drop index AUTOR_BUCH2_FK on AUTOR_BUCH; + +drop index AUTOR_BUCH_FK on AUTOR_BUCH; + +drop table if exists AUDIO; + +drop table if exists AUSLEIHE; + +drop table if exists AUTOR; + +drop table if exists AUTOR_BUCH; + +drop table if exists BUCH; + +drop table if exists ENTLEIHER; + +drop table if exists LEIHOBJEKT; + +drop table if exists ZEITSCHRIFT; + +/*==============================================================*/ +/* Table: AUDIO */ +/*==============================================================*/ +create table if not exists AUDIO +( + LEIHNR char(10) not null, + KATEGORIE char(2), + ATITEL varchar(30), + primary key (LEIHNR) +); + +/*==============================================================*/ +/* Table: AUSLEIHE */ +/*==============================================================*/ +create table if not exists AUSLEIHE +( + LEIHNR char(10) not null, + ENR char(10) not null, + DATUM date not null, + BACKDATE date, + OVER int, + primary key (LEIHNR, ENR, DATUM) +); + +/*==============================================================*/ +/* Index: RELATIONSHIP_4_FK */ +/*==============================================================*/ +create index RELATIONSHIP_4_FK on AUSLEIHE +( + LEIHNR +); + +/*==============================================================*/ +/* Index: RELATIONSHIP_5_FK */ +/*==============================================================*/ +create index RELATIONSHIP_5_FK on AUSLEIHE +( + ENR +); + +/*==============================================================*/ +/* Table: AUTOR */ +/*==============================================================*/ +create table if not exists AUTOR +( + ACODE char(7) not null, + ANAME varchar(20), + primary key (ACODE) +); + +/*==============================================================*/ +/* Table: AUTOR_BUCH */ +/*==============================================================*/ +create table if not exists AUTOR_BUCH +( + LEIHNR char(10) not null, + ACODE char(7) not null, + primary key (LEIHNR, ACODE) +); + +/*==============================================================*/ +/* Index: AUTOR_BUCH_FK */ +/*==============================================================*/ +create index AUTOR_BUCH_FK on AUTOR_BUCH +( + LEIHNR +); + +/*==============================================================*/ +/* Index: AUTOR_BUCH2_FK */ +/*==============================================================*/ +create index AUTOR_BUCH2_FK on AUTOR_BUCH +( + ACODE +); + +/*==============================================================*/ +/* Table: BUCH */ +/*==============================================================*/ +create table if not exists BUCH +( + LEIHNR char(10) not null, + ISBN char(15), + BTITEL varchar(30), + ERSCHJAHR int, + primary key (LEIHNR) +); + +/*==============================================================*/ +/* Table: ENTLEIHER */ +/*==============================================================*/ +create table if not exists ENTLEIHER +( + ENR char(10) not null, + ENAME varchar(20), + primary key (ENR) +); + +/*==============================================================*/ +/* Table: LEIHOBJEKT */ +/*==============================================================*/ +create table if not exists LEIHOBJEKT +( + LEIHNR char(10) not null, + LEIHTYP char(1) not null, + primary key (LEIHNR) +); + +/*==============================================================*/ +/* Table: ZEITSCHRIFT */ +/*==============================================================*/ +create table if not exists ZEITSCHRIFT +( + LEIHNR char(10) not null, + JAHRGANG int, + ZTITEL varchar(30), + primary key (LEIHNR) +); + diff --git a/Bachelor/Datenbanken 2/Praktikum3/bibdrop.sql b/Bachelor/Datenbanken 2/Praktikum3/bibdrop.sql new file mode 100644 index 0000000..38d6429 --- /dev/null +++ b/Bachelor/Datenbanken 2/Praktikum3/bibdrop.sql @@ -0,0 +1,89 @@ +/*==============================================================*/ +/* Database name: CONCEPTUALDATAMODEL_1 */ +/* DBMS name: ORACLE Version 9i */ +/* Created on: 29.03.2006 09:46:49 */ +/*==============================================================*/ + + +alter table AUDIO + drop constraint FK_AUDIO_INHERITAN_LEIHOBJE +/ + + +alter table AUSLEIHE + drop constraint FK_AUSLEIHE_RELATIONS_LEIHOBJE +/ + + +alter table AUSLEIHE + drop constraint FK_AUSLEIHE_RELATIONS_ENTLEIHE +/ + + +alter table AUTOR_BUCH + drop constraint FK_AUTOR_BU_AUTOR_BUC_BUCH +/ + + +alter table AUTOR_BUCH + drop constraint FK_AUTOR_BU_AUTOR_BUC_AUTOR +/ + + +alter table BUCH + drop constraint FK_BUCH_INHERITAN_LEIHOBJE +/ + + +alter table ZEITSCHRIFT + drop constraint FK_ZEITSCHR_INHERITAN_LEIHOBJE +/ + + +drop index RELATIONSHIP_4_FK +/ + + +drop index RELATIONSHIP_5_FK +/ + + +drop index AUTOR_BUCH2_FK +/ + + +drop index AUTOR_BUCH_FK +/ + + +drop table AUDIO cascade constraints +/ + + +drop table AUSLEIHE cascade constraints +/ + + +drop table AUTOR cascade constraints +/ + + +drop table AUTOR_BUCH cascade constraints +/ + + +drop table BUCH cascade constraints +/ + + +drop table ENTLEIHER cascade constraints +/ + + +drop table LEIHOBJEKT cascade constraints +/ + + +drop table ZEITSCHRIFT cascade constraints +/ + diff --git a/Bachelor/Datenbanken 2/Praktikum3/bibinsert.sql b/Bachelor/Datenbanken 2/Praktikum3/bibinsert.sql new file mode 100644 index 0000000..68e3cf8 --- /dev/null +++ b/Bachelor/Datenbanken 2/Praktikum3/bibinsert.sql @@ -0,0 +1,166 @@ +insert into entleiher values +('E0101','Jasmin Baumann'); +insert into entleiher values +('E0102','Jennifer Stock'); +insert into entleiher values +('E0103','Fabian Sack'); +insert into entleiher values +('E0104','Marcell Meier'); +insert into entleiher values +('E0105','Daniel Mueller'); +insert into entleiher values +('E0106','Caroline Meyer'); +insert into entleiher values +('E0107','Kathrin Mai'); +insert into entleiher values +('E0108','Michael Bauer'); + +insert into leihobjekt values +('L010','a'); +insert into leihobjekt values +('L011','b'); +insert into leihobjekt values +('L012','a'); +insert into leihobjekt values +('L013','b'); +insert into leihobjekt values +('L014','z'); +insert into leihobjekt values +('L015','z'); +insert into leihobjekt values +('L016','z'); +insert into leihobjekt values +('L017','b'); +insert into leihobjekt values +('L018','b'); +insert into leihobjekt values +('L019','b'); +insert into leihobjekt values +('L020','a'); +insert into leihobjekt values +('L021','a'); +insert into leihobjekt values +('L022','a'); +insert into leihobjekt values +('L023','b'); +insert into leihobjekt values +('L024','b'); +insert into leihobjekt values +('L025','b'); +insert into leihobjekt values +('L026','b'); +insert into leihobjekt values +('L027','b'); +insert into leihobjekt values +('L028','b'); + +insert into audio values +('L010','kl','Sonate A Dur'); +insert into audio values +('L012','ro','One night at the opera'); +insert into audio values +('L020','ro','Mensch'); +insert into audio values +('L021','ro','Just the best'); +insert into audio values +('L022','po','Bravo Hits'); + +insert into zeitschrift values +('L014',1999,'Focus'); +insert into zeitschrift values +('L015',2004,'Brigitte'); +insert into zeitschrift values +('L016',2005,'Stern'); + +insert into buch values +('L011','3-8218-1406-311','Mobby Dick',2001); +insert into buch values +('L013','9-7838-2353-223','Pippi Langstrumpf',1998); +insert into buch values +('L017','4-2546-2625-341','Kristall der Träuume',2000); +insert into buch values +('L018','3-2533-5862-134','Kochen fuer Anfaenger',2002); +insert into buch values +('L019','4-1235-3332-125','Backen leicht gemacht',2003); +insert into buch values +('L023','3-8218-1406-301','Studentenkueche',2004); +insert into buch values +('L024','9-7838-2233-223','Lockruf der Vergangenheit',2004); +insert into buch values +('L025','4-2116-2625-341','Bitteres Geheimnis',2001); +insert into buch values +('L026','3-2533-5876-134','Oliver Twist',2003); +insert into buch values +('L027','4-1235-1000-125','Das Weihnachtsgespenst',2001); +insert into buch values +('L028','3-8218-1578-351','Das Muffinkochbuch',2004); + +insert into autor values +('A0101','Astrid Lindgren'); +insert into autor values +('A0102','Charles Dickens'); +insert into autor values +('A0103','Annette Weiler'); +insert into autor values +('A0104','Barbara Wood'); + +insert into autor_buch values +('L013','A0101'); +insert into autor_buch values +('L011','A0102'); +insert into autor_buch values +('L018','A0103'); +insert into autor_buch values +('L019','A0103'); +insert into autor_buch values +('L017','A0104'); +insert into autor_buch values +('L024','A0104'); +insert into autor_buch values +('L025','A0104'); +insert into autor_buch values +('L026','A0102'); +insert into autor_buch values +('L027','A0102'); +insert into autor_buch values +('L023','A0103'); +insert into autor_buch values +('L028','A0103'); + +insert into ausleihe values +('L012','E0102','07.09.2005','02.11.2005',1); +insert into ausleihe values +('L028','E0103','12.11.2005','07.12.2005',0); +insert into ausleihe values +('L011','E0101','02.02.2006','02.03.2006',0); +insert into ausleihe values +('L012','E0101','03.01.2006','31.01.2006',1); +insert into ausleihe values +('L012','E0103','10.01.2006','08.02.2006',1); +insert into ausleihe values +('L013','E0103','10.01.2006','08.02.2006',1); +insert into ausleihe values +('L014','E0103','10.01.2006','08.02.2006',1); +insert into ausleihe values +('L015','E0104','03.02.2006','03.03.2006',0); +insert into ausleihe values +('L016','E0106','04.01.2006','01.02.2006',1); +insert into ausleihe values +('L017','E0107','05.01.2006','02.03.2006',1); +insert into ausleihe values +('L019','E0108','03.02.2006','03.03.2006',0); +insert into ausleihe values +('L020','E0108','03.02.2006','03.03.2006',0); +insert into ausleihe values +('L021','E0108','03.02.2006','03.03.2006',0); +insert into ausleihe values +('L024','E0108','03.02.2006','03.03.2006',0); +insert into ausleihe values +('L025','E0108','07.02.2006','07.03.2006',0); +insert into ausleihe values +('L026','E0108','07.02.2006','07.03.2006',0); +insert into ausleihe values +('L027','E0108','07.02.2006','07.03.2006',0); + + + diff --git a/Bachelor/Datenbanken 2/Praktikum3/selects.sql b/Bachelor/Datenbanken 2/Praktikum3/selects.sql new file mode 100644 index 0000000..9c4bf31 --- /dev/null +++ b/Bachelor/Datenbanken 2/Praktikum3/selects.sql @@ -0,0 +1,130 @@ +* DBII Praktikum 3 */ +/* ================ */ + +/* Aufgabe 1: */ +/* ---------- */ + +select ISBN, BTITEL from BUCH where LEIHNR in +(select LEIHNR from AUTOR_BUCH where ACODE in +(select ACODE from AUTOR where ANAME = 'Charles Dickens')); + +/* oder */ + +select ISBN,BTITEL from BUCH where LEIHNR in +(select ab.LEIHNR from Autor a, AUTOR_BUCH ab where a.ACODE = ab.ACODE and a.ANAME = 'Charles Dickens'); + +/* oder */ + +select b.ISBN,b.BTITEL +from Autor a, AUTOR_BUCH ab, BUCH b +where a.ACODE = ab.ACODE and ab.LEIHNR = b.LEIHNR and a.ANAME = 'Charles Dickens'; + + +/* Aufgabe 2: */ +/* ---------- */ + +select b.LEIHNR, b.ISBN, b.BTITEL, b.ERSCHJAHR +from Autor a, AUTOR_BUCH ab, BUCH b +where a.ACODE = ab.ACODE and ab.LEIHNR = b.LEIHNR and a.ANAME = 'Barbara Wood'; + + +select * from BUCH where LEIHNR in +(select LEIHNR from AUTOR_BUCH where ACODE in +(select ACODE from AUTOR where ANAME = 'Barbara Wood')); + + +/* Aufgabe 3: */ +/* ---------- */ + +select e.ENAME, a.DATUM, a.BACKDATE, a.OVER, o.LEIHTYP +from LEIHOBJEKT o, AUSLEIHE a, ENTLEIHER e +where o.LEIHNR = a.LEIHNR and a.ENR = e.ENR order by a.datum; + + +/* Aufgabe 4: */ +/* ---------- */ +SELECT e.ENAME, count(*) +FROM AUSLEIHE a, ENTLEIHER e +WHERE a.ENR = e.ENR and a.datum > '31.12.2005' +GROUP BY e.ENAME +having count(*) > 1 +order by count(*) desc; + + +/* Aufgabe 5: */ +/* ---------- */ +select b.BTITEL, b.ERSCHJAHR +from Autor a, AUTOR_BUCH ab, BUCH b +where a.ACODE = ab.ACODE and ab.LEIHNR = b.LEIHNR and a.ANAME = 'Annette Weiler' and b.ERSCHJAHR in +(select max(b.ERSCHJAHR) +from Autor a, AUTOR_BUCH ab, BUCH b +where a.ACODE = ab.ACODE and ab.LEIHNR = b.LEIHNR and a.ANAME = 'Annette Weiler'); + + +/* Aufgabe 6: */ +/* ---------- */ +select e.ENAME, a.DATUM, a.BACKDATE, a.OVER, o.LEIHTYP +from LEIHOBJEKT o, AUSLEIHE a, ENTLEIHER e +where o.LEIHNR = a.LEIHNR +and a.ENR = e.ENR +and ( o.LEIHTYP = 'a' or o.LEIHTYP ='z' ) +and (a.datum between '28.01.2006' and '05.02.2006'); + +/* Aufgabe 7: */ +/* ---------- */ +SELECT lo.leihnr LEIHNR, lo.leihtyp LEIHTYP, e.TITEL +from LEIHOBJEKT lo, +(SELECT z.leihnr NR,z.ztitel TITEL from ZEITSCHRIFT z +UNION +SELECT a.leihnr NR ,atitel TITEL from AUDIO a +UNION +SELECT b.leihnr NR, b.btitel TITEL FROM BUCH b) e +WHERE lo.leihnr=e.NR +ORDER BY LEIHTYP, e.TITEL; + +/* Aufgabe 8: */ +/* ---------- */ + +select e.ENAME, sum(a.OVER) * 2 +from AUSLEIHE a, ENTLEIHER e +where a.ENR = e.ENR +GROUP BY e.Ename +having sum(a.OVER) > 0; + +/* Aufgabe 9: */ +/* ---------- */ +select distinct a.acode,a.aname +from AUTOR a, autor_buch ab +WHERE a.acode=ab.acode and EXISTS (SELECT * + FROM ausleihe al + where ab.leihnr = al.leihnr); + +select a.acode,a.aname +from AUTOR a +WHERE EXISTS (SELECT * + FROM autor_buch ab, ausleihe al + where a.acode = ab.acode and ab.leihnr = al.leihnr); + + +/* Aufgabe 10: */ +/* ---------- */ +select b.leihnr, b.isbn from buch b +WHERE not EXISTS ( +SELECT * from ausleihe a where a.leihnr = b.leihnr); + +/* geht nicht */ + select * from buch + WHERE not EXISTS ( + SELECT * FROM BUCH Natural JOIN AUSLEIHE); + +/* Aufgabe 11: */ +/* ---------- */ + +select e.enr, e.ename from entleiher e +where exists (select * from ausleihe a where a.enr=e.enr + and a.over >0); +_______________________________________________________________ +SMS schreiben mit WEB.DE FreeMail - einfach, schnell und +kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192 + + -- cgit v1.2.3