Https://docs.microsoft.com/en-us/sql/relational-databases/tables/create-foreign-key-relationships
Answer:
boolean isEven = false;
if (x.length % 2 == 0)
isEven = true;
Comparable currentMax;
int currentMaxIndex;
for (int i = x.length - 1; i >= 1; i--)
{
currentMax = x[i];
currentMaxIndex = i;
for (int j = i - 1; j >= 0; j--)
{
if (((Comparable)currentMax).compareTo(x[j]) < 0)
{
currentMax = x[j];
currentMaxIndex = j;
}
}
x[currentMaxIndex] = x[i];
x[i] = currentMax;
}
Comparable a = null;
Comparable b = null;
if (isEven == true)
{
a = x[x.length/2];
b = x[(x.length/2) - 1];
if ((a).compareTo(b) > 0)
m = a;
else
m = b;
}
else
m = x[x.length/2];
Answer:
Hi Riahroo! This is a good question on the concept of relational databases.
We can normalize the relations as follows:
Flight
(flightnumber (unique), flighttime, airline_id, departure_city, arrival_city, passenger_id, pilot_id, airplane_id)
has_one_and_belongs_to :airline
has_many :passengers
has_one :pilot
Itinerary(passenger_id, flight_id)
Belongs_to
Passenger_details
(passengername (unique), gender, date_of_birth)
has_many :flights
Pilot
(pilotname (unique), gender, date_of_birth)
has_many :flights
airline(airlinename)
airplane(planeID, type, seats))
Explanation:
To normalize a relation, we have to remove any redundancies from the relationships between database objects/tables and simplify the structure. This also means simplifying many-to-many relationships. In this question, we see there is a many-to-many relationship between flights and passengers. To resolve this we can introduce a join table which simplifies this relationship to a one-to-many between the objects.