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:-
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:-
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:-
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:
Debian: "There is no public key available for the following key IDs"
jQuery: disable autoscrolling to top when click on anchor
WordPress: How to remove meta generator tag?
How to hide apache2 version number in error page
How to extract .deb file in Linux / Mac
How to insert new line (line break) in a cell - OpenOffice Calc
How to enable personal file sharing in Ubuntu 10.04
How to setup mysqldump without password in cronjob
Share this with your friends:-