Search code examples
database-designforeign-keysrelational-database

Sequence of foreign keys


I have an object type SPORTS ARENA that is supposed to lists all the sports held in that arena and an object type SPORT with all the infos about a sport:

SPORTS ARENA
name: string
sports: seq string

SPORT
name: string
disciplines: seq string

SPORTS ARENA <-->> SPORT (1:n) relationship, one sport can be held in only one arena (in this case it is like this) 
and one arena can hold multiple sports.

This is an objects scheme and I want to convert it in a relational scheme with primary keys and foreign keys.

Usually in (1:n) relations you put in one table an attribute as foreign key refering the primary key of the other table.

In this case I have to deal with a sequence, so do I have to make an attribute that is a sequence of foreign keys? or how would the relational scheme look like?


Solution

  • -- Arena ARE exists.
    --
    arena {ARE}
       PK {ARE}
    
    • Each sport can be held in exactly one arena; for each arena, that arena may hold more than one sport.
    -- Sport SPO is held in arena ARE.
    --
    sport {SPO, ARE}
       PK {SPO}
    
    FK {ARE} REFERENCES arena {ARE}
    

    Note:

    All attributes (columns) NOT NULL
    
    PK = Primary Key
    FK = Foreign Key