Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Didattica > Corsi A - F > Basi di dati ~ informatica triennale > Preparazione esame
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
mattiie
dsy developer

User info:
Registered: Oct 2010
Posts: 46 (0.01 al dì)
Location: milano
Corso: Informatica F94
Anno: Primo (Magistrale)
Time Online: 9:28:41 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Preparazione esame

Pubblico qua la mia preparazione all'esame di BD; consiste nella correzione dell'esame del 2009. Fatemi sapere se ci sono errori..

Attachment: preparazione_esame.rtf
This has been downloaded 124 time(s).

15-01-2012 17:06
Click Here to See the Profile for mattiie Click here to Send mattiie a Private Message Find more posts by mattiie Add mattiie to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Shaper
.consigliere.

User info:
Registered: Sep 2007
Posts: 147 (0.02 al dì)
Location: Milano
Corso: Informatica
Anno: Secondo anno
Time Online: 1 Day, 11:23:27 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Re: Preparazione esame

Originally posted by mattiie
Pubblico qua la mia preparazione all'esame di BD; consiste nella correzione dell'esame del 2009. Fatemi sapere se ci sono errori..


Ciao, intanto grazie per il post, poi per quanto riguarda l'SQL io ho fatto in maniera diversa:

PHP:

-- 22/sett/09 esercizio 1
-- matricola dei maestri che hanno solo assegnazioni di materie del loro stesso ambito

SELECT maestro.matricola 
FROM maestro, materia, assegnazione
WHERE materia.id = assegnazione.id
AND maestro.ambito = materia.ambito
AND maestro.matricola NOT IN 
(SELECT maestro.matricola
FROM maestro, materia, assegnazione
WHERE materia.id = assegnazione.id
AND maestro.matricola = assegnazione.matricola
AND maestro.ambito != materia.ambito)

-- 22/sett/09 esercizio 1
-- determinare, per ogni maestro di ambito matematico, il numero totale di assegnazioni
SELECT maestro.matricola, COUNT(*) AS numero_assegnazioni
FROM maestro, assegnazione
WHERE maestro.matricola = assegnazione.matricola
AND maestro.ambito = 'matematico'
GROUP BY maestro.matricola



A occhio direi che la prima fa la stessa cosa, solo in modo diverso.
Invece la seconda non l'ho proprio capita:
intanto la domanda dice che l'ambito matematico deve essere quello del MAESTRO, non della materia, quindi 'mt.ambito = om.ambito' penso sia sbagliato.
E poi da dove tiri fuori 'om.matricola'? Nel FROM hai elencato solo assegnazione a, materia mt)

Ho provato le query su un db di prova e i risultati erano coerenti, qualcuno ha altre soluzioni? :?

__________________
Eidolon64|Blog

15-01-2012 17:20
Click Here to See the Profile for Shaper Click here to Send Shaper a Private Message Visit Shaper's homepage! Find more posts by Shaper Add Shaper to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
mattiie
dsy developer

User info:
Registered: Oct 2010
Posts: 46 (0.01 al dì)
Location: milano
Corso: Informatica F94
Anno: Primo (Magistrale)
Time Online: 9:28:41 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Per quanto riguarda la prima, come dici te, sono assolutamente equivalenti. Solo ricorda che != va bene in C ma in SQL si scrive <>.
Per quanto riguarda la seconda, ho fatto un pasticcio col copia/incolla.
La versione corretta è:

SELECT m.nome, m.cognome, COUNT(*) as numero_assegnazioni
FROM assegnazione a, materia mt, maestro m
WHERE a.matricola = m.matricola AND mt.ambito = m.ambito AND mt.nome= 'Matematica'
GROUP BY m.matricola;

15-01-2012 17:31
Click Here to See the Profile for mattiie Click here to Send mattiie a Private Message Find more posts by mattiie Add mattiie to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Shaper
.consigliere.

User info:
Registered: Sep 2007
Posts: 147 (0.02 al dì)
Location: Milano
Corso: Informatica
Anno: Secondo anno
Time Online: 1 Day, 11:23:27 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by mattiie
Per quanto riguarda la prima, come dici te, sono assolutamente equivalenti. Solo ricorda che != va bene in C ma in SQL si scrive <>.


Hai ragione, a furia di andare avanti e indietro fra php e SQL mi sta andando insieme tutto! :P

Per la query, adesso è molto più chiara, però continuo a sostenere che invece di scrivere
mt.ambito = m.ambito AND mt.nome= 'Matematica'

bisogna scrivere
m.ambito = '_ambito_matematico_'

Infatti l'esercizio chiede "...per ogni maestro di AMBITO matematico..." e tu stai considerando la materia col NOME 'Matematica'
Mentre l'ambito si riferisce al maestro

Esempio:
Un maestro di ambito matematico insegnerà materie di ambito matematico, come algebra, geometria, trigonometria, ma nulla vieta che insegni materie anche di altri ambiti, come per esempio geografia. A riprova di ciò il primo punto chiede di selezionare maestri che hanno assegnazioni SOLO del loro stesso ambito (il che implica che ce ne siano con assegnazioni ad ambiti diversi)

__________________
Eidolon64|Blog

15-01-2012 17:43
Click Here to See the Profile for Shaper Click here to Send Shaper a Private Message Visit Shaper's homepage! Find more posts by Shaper Add Shaper to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
number15
.grande:maestro.

User info:
Registered: Nov 2005
Posts: 652 (0.09 al dì)
Location:
Corso:
Anno:
Time Online: 121 Days, 13:57:11 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Ex. 1 tu dici risposta C, ma essendo parziale/sovrapposta se tieni tutte 3 le tabelle devi riportare la chiave primaria della superclasse nelle sottoclassi. Per me l'unica possibile è la B.

Edit: tra l'altro i due attributi delle sottoclassi son normali attributi, non possono diventare chiavi.

__________________
Portale segnalazioni marchi-negozi di abbigliamento
http://www.ovojo.com

Last edited by number15 on 15-01-2012 at 17:59

15-01-2012 17:50
Click Here to See the Profile for number15 Click here to Send number15 a Private Message Find more posts by number15 Add number15 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
mattiie
dsy developer

User info:
Registered: Oct 2010
Posts: 46 (0.01 al dì)
Location: milano
Corso: Informatica F94
Anno: Primo (Magistrale)
Time Online: 9:28:41 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Hai ragione: ero concentrato sui vari modi per tradurla che non ho guardato i dettagli base XD

15-01-2012 18:14
Click Here to See the Profile for mattiie Click here to Send mattiie a Private Message Find more posts by mattiie Add mattiie to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 12:24.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.034 seconds (76.05% PHP - 23.95% MySQL) con 26 query.