wie sind flg. Tabellen miteinander verknüpft?

Tuts4you

Erfahrenes Mitglied
Hallo!

Ich hoffe ihr könnt mir helfen - ich hab nämlich schon "Schädelweh" weil ich nicht weiterkomme...

Welche Länder gibt es in Africa (absteigend sortiert nach ihrer Fläche) ?

db schaut folgendermaßen aus:
PHP:
CREATE TABLE Country
(Name VARCHAR2(32) NOT NULL UNIQUE,
 Code VARCHAR2(4) CONSTRAINT CountryKey PRIMARY KEY,
 Capital VARCHAR2(35) NOT NULL,
 Province VARCHAR2(32) NOT NULL,
 Area NUMBER CONSTRAINT CountryArea
   CHECK (Area >= 0),
 Population NUMBER CONSTRAINT CountryPop
   CHECK (Population >= 0));


CREATE TABLE City
(Name VARCHAR2(35) NOT NULL,
 Country VARCHAR2(4) references Country(Code) NOT NULL,
 Province VARCHAR2(32) NOT NULL,
 Population NUMBER CONSTRAINT CityPop
   CHECK (Population >= 0),
 Longitude NUMBER CONSTRAINT CityLon
   CHECK ((Longitude >= -180) AND (Longitude <= 180)) ,
 Latitude NUMBER CONSTRAINT CityLat
   CHECK ((Latitude >= -90) AND (Latitude <= 90)) ,
 CONSTRAINT CityKey PRIMARY KEY (Name,Country,Province));

CREATE TABLE Province
(Name VARCHAR2(32) CONSTRAINT PrName NOT NULL ,
 Country  VARCHAR2(4) references Country(Code) NOT NULL ,
 Population NUMBER CONSTRAINT PrPop
   CHECK (Population >= 0),
 Area NUMBER CONSTRAINT PrAr
   CHECK (Area >= 0),
 Capital VARCHAR2(35),
 CapProv VARCHAR2(32),
 CONSTRAINT PrKey PRIMARY KEY (Name,Country));


CREATE TABLE Continent
(Name VARCHAR2(20) CONSTRAINT ContinentKey PRIMARY KEY,
 Area NUMBER(10));

CREATE TABLE encompasses
(Country VARCHAR2(4) NOT NULL references Country(Code),
 Continent VARCHAR2(20) NOT NULL references Continent(Name),
 Percentage NUMBER,
   CHECK ((Percentage > 0) AND (Percentage <= 100)),
 CONSTRAINT EncompassesKey PRIMARY KEY (Country,Continent));
Inwieweit sind die einzelnen Tabellen miteinander verknüpft? Wie komme ich von Continent auf Countries? Danke für eure Hilfe!

Liebe Grüße Michael
 
Ist diese Abfrage richtig? Oder gibts eine bessere Lösung?
PHP:
select country.name as Laender_in_Afrika from country, encompasses where country.code = encompasses.country and encompasses.continent = 'Africa' order by country.area
 

Neue Beiträge

Zurück