| Neuer Benutzer
Registriert seit: 03.02.2010
Beiträge: 9
PHP-Kenntnisse: Anfänger
| Danke erstmal,
also meine bisherigen Abfragen (die auch so an sich Funktionieren würden) wären 6 Views die die jeweiliegn Joins enthalten die nötig sind um eine Person je nach gegebenheit (ob intern usw) angezeigt zubekommen. Code: /* intern UND student UND project*/
CREATE ALGORITHM = UNDEFINED VIEW `person_intern_student_project` AS
SELECT DISTINCT personID AS ID, lastName AS Lastname, firstName AS Firstname, nick AS Nickname, initials AS Initials,
title AS Title, nationality AS Nationality, birthdate AS Date_of_Birth, birthplace AS Birthplace,
firstContact AS Firstcontact, workAs AS Jobtitle, note AS Commant, institution AS Institution,
street AS Street, streetNo AS Streetnumber, zipcode AS Zipcode, city AS City, country AS Country,
email AS Emailaddress, phoneNo AS Phonenumber, faxNo AS Faxnumber, employer AS Employer,
workgrp AS Workgroup, supervisor AS Supervisor, lastDegree AS Lastest_Degree, lastDegreeDate AS Latest_Degree_Date,
lastDegreeWhere AS Latest_Degree_Where, contractBegin AS Begin_of_Contract, contractEnd AS End_of_Contract,
hoursPerWeek AS Hours_per_Week, tvl AS Salary_level, listName AS List, projectNo AS Projectnumber,
projectTitle AS Projecttitle, projectShort AS Porjectshortcut, thirdPartyDisposer AS Third_Party_Disposer, room AS Room,
course1 AS First_Course, course2 AS Second_Course, matrNo AS Matrikelnumber, submittionDate AS Submittingdate,
defenseDate AS Defensedate, service AS Service, unit AS Unit, url AS Homepage
FROM person, intern, room, student, projectRef, project,
listRef, list, url, fax, email, phone, address, unit
WHERE person.personID = intern.person_personID AND
room.intern_internID = intern.internID AND
student.intern_internID = intern.internID AND
person.personID = projectRef.person_personID AND
project.projectID = projectRef.project_projectID AND
person.personID = listRef.person_personID AND
listRef.list_listID = list.listID AND
url.person_personID = person.personID AND
fax.person_personID = person.personID AND
email.person_personID = person.personID AND
phone.person_personID = person.personID AND
address.person_personID = person.personID AND
address.addressID = unit.address_addressID
order by personID
/* intern KEIN student KEIN project*/
CREATE ALGORITHM = UNDEFINED VIEW `person_intern_nostudent_noproject` AS
SELECT DISTINCT personID AS ID, lastName AS Lastname, firstName AS Firstname, nick AS Nickname, initials AS Initials,
title AS Title, nationality AS Nationality, birthdate AS Date_of_Birth, birthplace AS Birthplace,
firstContact AS Firstcontact, workAs AS Jobtitle, note AS Commant, institution AS Institution,
street AS Street, streetNo AS Streetnumber, zipcode AS Zipcode, city AS City, country AS Country,
email AS Emailaddress, phoneNo AS Phonenumber, faxNo AS Faxnumber, listName AS List, employer AS Employer,
workgrp AS Workgroup, supervisor AS Supervisor, lastDegree AS Lastest_Degree, lastDegreeDate AS Latest_Degree_Date,
lastDegreeWhere AS Latest_Degree_Where, contractBegin AS Begin_of_Contract, contractEnd AS End_of_Contract,
hoursPerWeek AS Hours_per_Week, tvl AS Salary_level, room AS Room,
unit AS Unit, url AS Homepage
FROM person, intern, room, listRef, list, url, fax,
email, phone, address, unit
WHERE person.personID = intern.person_personID AND
room.intern_internID = intern.internID AND
listRef.list_listID = list.listID AND
person.personID = listRef.person_personID AND
url.person_personID = person.personID AND
fax.person_personID = person.personID AND
email.person_personID = person.personID AND
phone.person_personID = person.personID AND
address.person_personID = person.personID AND
address.addressID = unit.address_addressID
order by personID
/* intern UND student KEIN project */
CREATE ALGORITHM = UNDEFINED VIEW `person_intern_student_noproject` AS
SELECT DISTINCT personID AS ID, lastName AS Lastname, firstName AS Firstname, nick AS Nickname, initials AS Initials,
title AS Title, nationality AS Nationality, birthdate AS Date_of_Birth, birthplace AS Birthplace,
firstContact AS Firstcontact, workAs AS Jobtitle, note AS Commant, institution AS Institution,
street AS Street, streetNo AS Streetnumber, zipcode AS Zipcode, city AS City, country AS Country,
email AS Emailaddress, phoneNo AS Phonenumber, faxNo AS Faxnumber, listName AS List, employer AS Employer,
workgrp AS Workgroup, supervisor AS Supervisor, lastDegree AS Lastest_Degree, lastDegreeDate AS Latest_Degree_Date,
lastDegreeWhere AS Latest_Degree_Where, contractBegin AS Begin_of_Contract, contractEnd AS End_of_Contract,
hoursPerWeek AS Hours_per_Week, tvl AS Salary_level, room AS Room,
course1 AS First_Course, course2 AS Second_Course, matrNo AS Matrikelnumber, submittionDate AS Submittingdate,
defenseDate AS Defensedate, service AS Service, unit AS Unit, url AS Homepage
FROM person, intern, room, student,
listRef, list, url, fax, email, phone, address, unit
WHERE person.personID = intern.person_personID AND
room.intern_internID = intern.internID AND
student.intern_internID = intern.internID AND
listRef.list_listID = list.listID AND
person.personID = listRef.person_personID AND
url.person_personID = person.personID AND
fax.person_personID = person.personID AND
email.person_personID = person.personID AND
phone.person_personID = person.personID AND
address.person_personID = person.personID AND
address.addressID = unit.address_addressID
order by personID
/* intern KEIN student ABER project */
CREATE ALGORITHM = UNDEFINED VIEW `person_intern_nostudent_project` AS
SELECT DISTINCT personID AS ID, lastName AS Lastname, firstName AS Firstname, nick AS Nickname, initials AS Initials,
title AS Title, nationality AS Nationality, birthdate AS Date_of_Birth, birthplace AS Birthplace,
firstContact AS Firstcontact, workAs AS Jobtitle, note AS Commant, institution AS Institution,
street AS Street, streetNo AS Streetnumber, zipcode AS Zipcode, city AS City, country AS Country,
email AS Emailaddress, phoneNo AS Phonenumber, faxNo AS Faxnumber, listName AS List, employer AS Employer,
workgrp AS Workgroup, supervisor AS Supervisor, lastDegree AS Lastest_Degree, lastDegreeDate AS Latest_Degree_Date,
lastDegreeWhere AS Latest_Degree_Where, contractBegin AS Begin_of_Contract, contractEnd AS End_of_Contract,
hoursPerWeek AS Hours_per_Week, tvl AS Salary_level, projectNo AS Projectnumber,
projectTitle AS Projecttitle, projectShort AS Porjectshortcut, thirdPartyDisposer AS Third_Party_Disposer, room AS Room,
unit AS Unit, url AS Homepage
FROM person, intern, room, projectRef, project,
listRef, list, url, fax, email, phone, address, unit
WHERE person.personID = intern.person_personID AND
room.intern_internID = intern.internID AND
person.personID = projectRef.person_personID AND
project.projectID = projectRef.project_projectID AND
listRef.list_listID = list.listID AND
person.personID = listRef.person_personID AND
url.person_personID = person.personID AND
fax.person_personID = person.personID AND
email.person_personID = person.personID AND
phone.person_personID = person.personID AND
address.person_personID = person.personID AND
address.addressID = unit.address_addressID
order by personID
/* KEIN intern KEIN student KEIN project*/
CREATE ALGORITHM = UNDEFINED VIEW `person_nointern_nostudent_noproject` AS
SELECT DISTINCT personID AS ID, lastName AS Lastname, firstName AS Firstname, nick AS Nickname, initials AS Initials,
title AS Title, nationality AS Nationality, birthdate AS Date_of_Birth, birthplace AS Birthplace,
firstContact AS Firstcontact, workAs AS Jobtitle, note AS Commant, institution AS Institution,
street AS Street, streetNo AS Streetnumber, zipcode AS Zipcode, city AS City, country AS Country,
email AS Emailaddress, phoneNo AS Phonenumber, faxNo AS Faxnumber, listName AS List, unit AS Unit, url AS Homepage
FROM person, listRef, list, url, fax, email, phone, address, unit
WHERE listRef.list_listID = list.listID AND
person.personID = listRef.person_personID AND
url.person_personID = person.personID AND
fax.person_personID = person.personID AND
email.person_personID = person.personID AND
phone.person_personID = person.personID AND
address.person_personID = person.personID AND
address.addressID = unit.address_addressID
order by personID
/* KEIN intern KEIN student ABER project */
CREATE ALGORITHM = UNDEFINED VIEW `person_nointern_nostudent_project` AS
SELECT DISTINCT personID AS ID, lastName AS Lastname, firstName AS Firstname, nick AS Nickname, initials AS Initials,
title AS Title, nationality AS Nationality, birthdate AS Date_of_Birth, birthplace AS Birthplace,
firstContact AS Firstcontact, workAs AS Jobtitle, note AS Commant, institution AS Institution,
street AS Street, streetNo AS Streetnumber, zipcode AS Zipcode, city AS City, country AS Country,
email AS Emailaddress, phoneNo AS Phonenumber, faxNo AS Faxnumber, listName AS List, projectNo AS Projectnumber,
projectTitle AS Projecttitle, projectShort AS Porjectshortcut, thirdPartyDisposer AS Third_Party_Disposer,
unit AS Unit, url AS Homepage
FROM person, projectRef, project,
listRef, list, url, fax, email, phone, address, unit
WHERE person.personID = projectRef.person_personID AND
project.projectID = projectRef.project_projectID AND
person.personID = listRef.person_personID AND
listRef.list_listID = list.listID AND
url.person_personID = person.personID AND
fax.person_personID = person.personID AND
email.person_personID = person.personID AND
phone.person_personID = person.personID AND
address.person_personID = person.personID AND
address.addressID = unit.address_addressID
order by personID
Wie gesagt sollte entweder eine Tabelle in der Ausgabe entstehen die die Ausgabe so darsetllen wie in den Views von mir oder eine Tabelle wo die Zellen die für eine Person die zb nicht intern ist, leer ausgegeben werden, wobei ich denke das 2. Variante einfache ist und erste schöner...
und "schießt den Server ab" soll bedeuten das eine Abfrage (vorallem die die für intern student raum und project gilt) zu lange braucht und ein timeout (nach 60 sec) ensteht... was, denke ich, an der Bildung der Kreuzprodukte der Joins liegt...
Die EXPLAIN - "Bilder" lass ich erstmal weg da das jetzt noch sehr viel Platz wegnehmen würde, zu not Poste ich die noch...
Gimpel |