-2

STRUCTURE:

Student: First name, last name ,date of birth, image.

class:name, section

course:name,description

grades:student,course,class

So i'm struggling to create this database in symfony with doctrine ORM , if someone can help with the entities(especially the foreign keys) it will be greatly appreciated.

Thank you.

1 Answers1

1

I suggest you to use the maker component to create your entities (composer require maker --dev). Also, the integration of Doctrine with Symfony is described here.

FIRST

bin/console make:entity Student  # then just answer the question
bin/console make:entity ClassRoom  # or anything different than "Class" as it looks like the "class" keyword
bin/console make:entity Course 
bin/console make:entity Grades

When creating the Grades entity, choose the type ManyToOne (or OneToOne, can't guess with your description) for your three properties student, course and classRoom.

More information about association mapping here.

NEXT

Then open your entities and enhance your @Column and @ManyToOne annotations.

Considers adding a @UniqueConstraint on the Grade entity wrapping your three properties if needed.

Considers adding a @JoinColumn constraint under your three Grade properties.

FINALLY

bin/console make:migration
bin/console doctrine:migrations:migrate
rugolinifr
  • 1,211
  • 1
  • 5
  • 11