.dsy:it.
Show 150 posts per page

.dsy:it. (http://www.dsy.it/forum/)
- Basi di dati ~ comunicazione digitale (http://www.dsy.it/forum/forumdisplay.php?forumid=108)
-- Basi di dati:soluzioni?? (http://www.dsy.it/forum/showthread.php?threadid=2685)


Posted by Alis on 09-02-2003 20:23:

Question Basi di dati:soluzioni??

Abbiamo fatto degli esercizi, ma non siamo sicuri dei risultati, ci potete dire se sono giusti?

Grazie!!!!!!!!!!!!!

Esame 13/01/03:

Esercizio 1:
A) SELECT DISTINCT IndirizzoFornitore
FROM Computer, Installazione
WHERE Computer.CodComputer=Installazione.CodComputer
AND descrizioneSoftware="database";

B) SELECT Marca, Modello, COUNT(CodComputer)
FROM Computer
GROUP BY Marca, Modello;

C) SELECT CodFornitore, MAX(COUNT(CodComputer))
FROM Computer
GROUP BY CodFornitore;

Esercizio 3:
CREATE TABLE R1(K Integer not null, A Integer)
PRIMARY KEY (K);
GRANT SELECT ON R1 TO Rossi;

CREATE TABLE R2(K Integer not null, B Integer)
PRIMARY KEY (K);
GRANT SELECT ON R2 TO Rossi;

INSERT INTO R1(K, A)
SELECT K, A
FROM R;

INSERT INTO R2(K, B)
SELECT K, B
FROM R;

DROP TABLE R;

CREATE VIEW R(K, A, B) AS
SELECT K, A, B
FROM R1, R2
WHERE R1.K=R2.K;


Esame 11/6/99:

Esercizio 1:
SELECT MAX(Prezzo), MIN(Prezzo), Nome
FROM Vendite, Auto, Venditori
WHERE Venditori.Vcod=Vendite.Vcod AND Auto.Acod=Vendite.Acod
AND Età <30 AND Marca="Toyota" AND Modello="Carina"
GROUP BY Nome;


Esame 20/6/02:

Esercizio 1:
B) SELECT Autore#, MIN(COUNT(Libro#))
FROM Libri, Prestiti
WHERE Libri.Libro#=Prestiti.Libro#
GRUOP BY Autore#;

C) DELETE FROM Libri
WHERE Argomento-Principale="Teoria degli Algoritmi"
Libro IN (SELECT Libro FROM Prestiti
WHERE Nome-Utente="Rossi");


Esame 2/9/02:

Esercizio 1: A) SELECT DISTINCT IndirizzoFornitore
FROM Computer, Installazione
WHERE Computer.CodComputer=
Installazione.CodComputer AND
dataInstallazione < #1/1/95#;


Posted by ripe on 10-02-2003 11:40:

Angry

Dai, qualcuno che risponda!!! :(

Ne mettiamo su un altro, del 20/06/2002, il numero 3:

a)

Tom: GRANT select, insert ON R TO Alice, Sam WITH GRANT OPTION;
Tom: GRANT delete ON R TO Alice;
Sam: GRANT select ON R TO Ann WITH GRANT OPTION;
Ann: GRANT select ON R TO Matt WITH GRANT OPTION;
Alice: GRANT select, insert ON R TO Matt, Ann WITH GRANT OPTION;
Matt: GRANT insert, select ON R TO Helen;
Tom: REVOKE select, insert, delete ON R FROM Alice;

b) Dopo il comando di revoca, Matt, Ann ed Helen possono eseguire solamente operazioni di SELECT.

Per favore, prima di giovedì!!!!!!!! :cry:

__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»


Posted by mimasuper on 10-02-2003 12:29:

Riguardo all'esame del 13-01-03 il C dell'esercizio 1 è sbagliato. Ne sono sicura xchè anch'io l'ho fatto così all'esame e me l'ha segnato. Non so sinceramente come si faccia, ma so che non puoi fare MAX(COUNT(CodComputer). Per il resto gli altri mi sembrano giusti, xchè anch'io li ho fatti così. In bocca al lupo!:)


Posted by ripe on 10-02-2003 12:42:

Grazie, proveremo a rivederlo un attimo!

__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»


Posted by imation on 10-02-2003 13:32:

Originally posted by mimasuper
Riguardo all'esame del 13-01-03 il C dell'esercizio 1 è sbagliato. Ne sono sicura xchè anch'io l'ho fatto così all'esame e me l'ha segnato. Non so sinceramente come si faccia, ma so che non puoi fare MAX(COUNT(CodComputer). Per il resto gli altri mi sembrano giusti, xchè anch'io li ho fatti così. In bocca al lupo!:)


anch'io l'avevo pensato così ma ho visto che nn si può fare (lo stesso vale per Esame 20/6/02: Esercizio 1: B) SELECT Autore#, MIN(COUNT(Libro#)))... mi sono scervellato ma nn ho trovato soluzione...

se avete qualche idea mi dareste una mano...


Posted by Alis on 10-02-2003 18:54:

Grazie mimaaaaaaaaaaaa!!!!!!!!!!!:D


Posted by Lunik on 10-02-2003 18:59:

potete sempre testare le query con mySql...

__________________
Il DSY su Facebook!!!


Posted by ripe on 10-02-2003 19:31:

Con Access mi vanno, ma lei le considera sbagliate!

__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»


Posted by Lunik on 10-02-2003 19:34:

Lei chi?
strano..Access.....con non so che pulsantino vedevi il codice SQL...che è un po' da modificare xè non è quello standard...

__________________
Il DSY su Facebook!!!


Posted by imation on 11-02-2003 01:08:

SELECT CodFornitore, COUNT(CodComputer)
FROM Computer
GROUP BY CodFornitore
ORDER BY COUNT(CodComputer) DESC
FETCH FIRST ROW ONLY;

...questo comando dovrebbe prendere solo la prima tupla del risultato, quindi quella con il maggior numero di computer...


Posted by ripe on 11-02-2003 07:27:

Il problema è che non ho mai visto questo FETCH a lezione, pensa che non ha neanche spiegato TOP n, che permette di scegliere le prime n righe!

__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»


Posted by ripe on 11-02-2003 07:32:

Molto interessante questo link:

Clicca qui per le funzioni di gruppo a due livelli

Leggete soprattutto l'ultima parte in fondo!!!

__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»


Posted by Lunik on 11-02-2003 09:57:

:D
Qualcuno vuole la traduzione di quel che c'è scritto nel link di Ripe?

:asd:

__________________
Il DSY su Facebook!!!


Posted by Vale on 12-02-2003 13:16:

io per il punto (c) del primo esercizio del 13/01 ho fatto così

select distinct c.codFornitore from
computer c,
(select codFornitore, count(*) as b from computer group by codFornitore) t

WHERE
b=(select max(a) from (select count(*) as a from computer group by codfornitore) h)
and c.codfornitore=t.codfornitore

che ne pensate?


X Ripe

l'esercizio del20/06/02 è corretto secondo me puoi essere più preciso dicendo che Matt e Ann hanno diritti di Select con grant option, mentre helen solo select


Posted by imation on 12-02-2003 14:52:

Originally posted by Vale
WHERE
b=(select max(a) from (select count(*) as a from computer group by codfornitore) h)
and c.codfornitore=t.codfornitore



qui penso ci sia un errore, xchè nn si può impostare condizioni sul count(funzione di gruppo) con il where... dovresti farlo con un having...


Posted by Vale on 12-02-2003 15:15:

cioè come faresti?


Posted by Alis on 12-02-2003 16:48:

Noi l'abbiamo rifatto così:

13/01/03:
Esercizio 1/C:

SELECT CodFornitore
FROM Computer
GROUP BY CodFornitore
HAVING COUNT (*) >= ALL (SELECT COUNT (*) FROM Computer GROUP BY CodFornitore);


Esercizio 3:

CREATE TABLE R1(K Integer not null, A Integer)
PRIMARY KEY (K);

CREATE TABLE R2(K Integer not null, B Integer)
PRIMARY KEY (K);

INSERT INTO R1(K, A)
SELECT K, A
FROM R;

INSERT INTO R2(K, B)
SELECT K, B
FROM R;

DROP TABLE R;

CREATE VIEW R(K, A, B) AS
SELECT R1.K, A, B
FROM R1, R2
WHERE R1.K=R2.K;

GRANT SELECT ON R TO Rossi;


In bocca al lupo per domani!!!!


Posted by Lunik on 12-02-2003 16:50:

giusti

__________________
Il DSY su Facebook!!!


Posted by Alis on 12-02-2003 16:53:

Originally posted by Lunik
giusti



:D :D :cool:


Posted by Lunik on 12-02-2003 17:15:

:D
Speriamo che domani ci sia qualcosa di simile... :asd:

__________________
Il DSY su Facebook!!!


Posted by Alis on 12-02-2003 17:21:

Speriamo!!!!!


Posted by Lunik on 12-02-2003 17:22:

*sgrat sgrat*

:D

__________________
Il DSY su Facebook!!!


Posted by imation on 12-02-2003 17:44:

Originally posted by Alis
Noi l'abbiamo rifatto così:

13/01/03:
Esercizio 1/C:

SELECT CodFornitore
FROM Computer
GROUP BY CodFornitore
HAVING COUNT (*) >= ALL (SELECT COUNT (*) FROM Computer GROUP BY CodFornitore);


perfetto!! grazie alis


Posted by Alis on 12-02-2003 17:49:

Originally posted by imation
perfetto!! grazie alis


Di niente!!


Posted by otty2907 on 12-02-2003 18:14:

RAga .. giusto per capire .. se si può dategli una occhiata :

SELECT CodFornitore
FROM Computer
WHERE MAX (SELECT COUNT (*)
FROM Computer Where GROUP BY CodFornitore)

é possibile utilizzare cosi --MAX ... GRazie


Posted by Lunik on 12-02-2003 18:17:

così si...ma quel Where solo.... no... ;)

__________________
Il DSY su Facebook!!!


Posted by otty2907 on 12-02-2003 18:20:

RAgazzi potete scrivere due righe sui JOIN (vari tipologie) e spiegarmi in che occasione utilizzarli ... grazie


Posted by Lunik on 12-02-2003 18:21:

Ma non hai il libro??? O le slides della prof? Lì è tutto spiegato bene!

posto qualche esercizio che ho ricevuto da Francesco, potrà essere utile.

__________________
Il DSY su Facebook!!!


Posted by Lunik on 12-02-2003 18:23:

rettifica: NON posso postare quel file xè coperto da copyright...

:wall:

__________________
Il DSY su Facebook!!!


Posted by ev619970 on 12-02-2003 18:30:

grande alice


Posted by imation on 12-02-2003 18:42:

nn sono sicuro ma anche l'esercizio b del tema del 20/06/2002 sembra sbagliato...

SELECT Autore#
FROM Libri,Prestiti
WHERE LibriLibro#=Prestiti.Libro# AND Nome-utente IS NOT NULL
GROUP BY Autore#
HAVING COUNT(Libro#)<=(SELECT Count(Libro#)
FROM Libri,Prestiti
WHERE LibriLibro#=Prestiti.Libro# AND Nome-utente IS NOT NULL
GROUP BY Autore#)


Posted by Alis on 12-02-2003 19:13:

Originally posted by imation
nn sono sicuro ma anche l'esercizio b del tema del 20/06/2002 sembra sbagliato...

SELECT Autore#
FROM Libri,Prestiti
WHERE LibriLibro#=Prestiti.Libro# AND Nome-utente IS NOT NULL
GROUP BY Autore#
HAVING COUNT(Libro#)<=(SELECT Count(Libro#)
FROM Libri,Prestiti
WHERE LibriLibro#=Prestiti.Libro# AND Nome-utente IS NOT NULL
GROUP BY Autore#)



Perchè hai messo IS NOT NULL?che io sappia si usa nelle creazioni di tabelle!!


Posted by Lunik on 12-02-2003 19:14:

azz Alis lo puoi usare anche nelle query...

__________________
Il DSY su Facebook!!!


Posted by Alis on 12-02-2003 19:18:

Ops non lo sapevo!grazie Lunik!!

per imation:oggi ho rifatto l'esercizio del 20/6/02, non so se è giusto,te lo posto lo stesso,cos' dai una occhiata!!!

SELECT Autore#
FROM Libri, Prestiti
WHERE Libri.Libro#=Prestiti.Libro#
GROUP BY Autore#
HAVING COUNT(*) >= ALL (SELECT COUNT(*) FROM Libri, Prestiti
WHERE Libri.Libro#=Prestiti.Libro#
GROUP BY Autore#


Posted by Alis on 12-02-2003 19:21:

Originally posted by Alis
Ops non lo sapevo!grazie Lunik!!

per imation:oggi ho rifatto l'esercizio del 20/6/02, non so se è giusto,te lo posto lo stesso,cos' dai una occhiata!!!

SELECT Autore#
FROM Libri, Prestiti
WHERE Libri.Libro#=Prestiti.Libro#
GROUP BY Autore#
HAVING COUNT(*) <= ALL (SELECT COUNT(*) FROM Libri, Prestiti
WHERE Libri.Libro#=Prestiti.Libro#
GROUP BY Autore#


Posted by Lunik on 12-02-2003 19:24:

Off-Topic:
che hai fatto Alis???? Cosa volevi fare quotando il tuo post???

__________________
Il DSY su Facebook!!!


Posted by Alis on 12-02-2003 19:29:

Originally posted by Lunik
Off-Topic:
che hai fatto Alis???? Cosa volevi fare quotando il tuo post???



Volevo solo correggere l'esercizio!!avevo messo > al posto di <!!


Posted by Lunik on 12-02-2003 19:29:

Off-Topic:
ah scusa non si vedeva... :)

__________________
Il DSY su Facebook!!!


Posted by imation on 12-02-2003 20:01:

Originally posted by Alis
Ops non lo sapevo!grazie Lunik!!

per imation:oggi ho rifatto l'esercizio del 20/6/02, non so se è giusto,te lo posto lo stesso,cos' dai una occhiata!!!

SELECT Autore#
FROM Libri, Prestiti
WHERE Libri.Libro#=Prestiti.Libro#
GROUP BY Autore#
HAVING COUNT(*) >= ALL (SELECT COUNT(*) FROM Libri, Prestiti
WHERE Libri.Libro#=Prestiti.Libro#
GROUP BY Autore#


io aggiungerei anche Nome-Utente IS NOT NULL in modo da evitare che siano selezionati anche i libri che non sono in prestito...


Posted by Lunik on 12-02-2003 20:12:

è inutile mettere IS NOT NUll...
nell'ultima select confrontando i codici dei libri PER FORZA fa un confronto tra libri in prestito..
fidati..è giusta...
forse il controllo nella prima select è inutile....

__________________
Il DSY su Facebook!!!


Posted by imation on 12-02-2003 20:17:

secondo me dipende da come è strutturata la base di dati.... nel senso che la relazione Prestiti potrebbe tenere memorizzati cmq tutti i libri e inserire nella colonna Nome-utente NULL se il libro nn è in prestito... nelle indicazioni nn è specificato


Posted by Lunik on 12-02-2003 20:18:

beh penso che se un libro non è in prestito, non è nella tabella prestiti!
mi sembra cmq anche ovvio...in un tema d'esame, simile a questo, ci sono 4 tabelle...e c'è proprio questa cosa "i libri in prestito NON sono nella tabella prestiti"

cmq....

__________________
Il DSY su Facebook!!!


All times are GMT. The time now is 01:52.
Show all 42 posts from this thread on one page

Powered by: vBulletin Version 2.3.1
Copyright © Jelsoft Enterprises Limited 2000 - 2002.