This symfony doctrine schema relationship sample is for my own reference. I think many people out there also facing the same problem as me when writing the doctrine schema relationship. Here are some of the relationship sample that give a very simple sample.
Advertisements
One to One relationship between User and Profile:-
1 2 3 4 5 6 7 8 9 10 11 12 |
Profile: columns: user_id: integer name: string(255) email_address: type: string(255) relations: User: local: user_id foreign: id type: one foreignType: one |
One to Many relationship between User and Phonenumber:-
1 2 3 4 5 6 7 8 9 10 11 |
Phonenumber: columns: user_id: integer phonenumber: string(255) relations: User: foreignAlias: Phonenumbers local: user_id foreign: id type: one foreignType: many |
Many to Many relation between BlogPost and Tag:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
BlogPost: columns: user_id: integer title: string(255) body: clob relations: User: local: user_id foreign: id type: one foreignType: one foreignAlias: BlogPosts Tags: class: Tag foreignAlias: BlogPosts refClass: BlogPostTag local: blog_post_id foreign: tag_id Tag: columns: name: string(255) BlogPostTag: columns: blog_post_id: type: integer primary: true tag_id: type: integer primary: true relations: BlogPost: local: blog_post_id foreign: id foreignAlias: BlogPostTags Tag: local: tag_id foreign: id foreignAlias: BlogPostTags |
Credit: Symfony Documentation
Related posts:
Speed Up and Save Your Website Bandwidth with GZip Compression
How to backup MySQL Database in command line with compression
How to extract .deb file in Linux / Mac
How to import contacts from Mac to Nokia N900
How to setup mysqldump without password in cronjob
PHP Fatal error: Class ‘DOMDocument’ not found in …
How to clear play history in VLC media player
Contact Form 7: Clear all field except specific after submission
Share this with your friends:-