사람들이 개인 프로파일을 열도록 웹 사이트를위한 데이터베이스 구조를 설계하려고합니다. 내가 선택한 디자인이 충분히 좋은지 알아 내려고 노력 중입니다. 문제가 될 수 있다고 생각하는 이유는 여러 테이블간에 많은 관계를 사용하고 있기 때문입니다. 이렇게하면 사람의 페이지가로드 될 때 장면 뒤에 많은 조인이 있으며 병목 현상이 발생합니다. 디자인이 적절한지 또는 재검토해야하는지 알아내는 데 도움을 주시면 감사하겠습니다. Django로 데이터베이스 구조 설계하기
그래서 나는 다음과 같은 디자인으로 올라와있다 : 각 페이지에 대해 적어도 5 테이블 조인가로드 된 것을 가class Person(models.Model):
GENDER_CHOICES = (
('M', 'Male'),
('F', 'Female'),
)
name = models.CharField(max_length=200)
# Each person can have one profession
profession = models.ForeignKey(Profession)
email = models.CharField(max_length=100, blank=True)
website = models.CharField(max_length=200, blank=True)
gender = models.CharField(max_length=1, choices=GENDER_CHOICES))
birth_date = models.DateField(blank=True, null=True)
class Profession(models.Model):
type = models.CharField(max_length=20, blank=False, choices = ("Teacher","Pilot","Politician"))
#Each person can have several geolocations (represent the person's home/office/other address)
class Geolocation(models.Model):
latitude = models.FloatField()
longitude = models.FloatField()
address = models.TextField()
related_person = models.ForeignKey(Person, blank=False, null=False)
#Each person can have several medias (you tube movies)
class Media(models.Model):
youtube_id = models.CharField(max_length=100)
related_person = models.ForeignKey(Person, blank=False, null=False)
#Each person can have several websites
class Websites(models.Model):
website_url = models.CharField(max_length=200, blank=False)
website_name = models.CharField(max_length=200)
related_person = models.ForeignKey(Person, blank=False, null=False)
#See below...
related_link_farm = models.ForeignKey(LinkFarms, blank=True, null=True)
#Each website that refers to a person must be also refered to a link farm
class LinkFarms(models.Model):
farm_name = models.CharField(max_length=200, blank=False)
알 수 있습니다.
감사합니다,
메이어