Search code examples
javasqlcollectionsclass-diagram

Collection in class diagram to SQL


How to convert a Collection attribute in a class diagram to SQL?

For example, a school class with a Students collections.

Will it be a one-to-many relationships? Do I have to create a Student table with a foreign key referencing the school?

Thanks


Solution

  • Yes that is correct. It is typically implemented as a child table with a foreign key pointing to the parent. In your example there will be a foreign key called schoolId on on the Students table.