设计一个简单的类似 IMDB 风格的数据库,使用面向对象编程(OOP)。

huangapple 未分类评论44阅读模式
英文:

Designing a simple IMDB style database with OOP

问题

以下是翻译好的部分:

这是一个通用的面向对象编程问题,但我需要在Java中找出解决方案。

本学期我有一个小组项目,目标是创建一个管理电视内容积分的数据库系统。因此,数据库将包含演员和工作人员的姓名、制作、制作公司等信息。

我们需要设计一个能够在表格之间进行交叉引用的数据库(类似于imdb),这样,如果您要选择一个"Person"对象,您将能够获取到此人参与的每个制作以及他们所担任的角色。如果需要帮助,可以考虑类似于imdb的情况。

我们对在SQL数据库中使用不同的表来完成这一点感到非常有信心,但在第二次迭代之前,我们不打算实现持久化层。

我们的教师表示,我们需要首先设计我们的领域/业务层,使用对象,并使数据库"效仿"这些对象。

所以我的问题是:我们如何设计可以以这种方式相互交叉引用的对象和类?

英文:

This is a general OOP type question but I’ll need to work out the solution in Java.

I have a group project this semsester where the goal is to create a database system that manages credits for TV content. The database will therefore contain cast and crew members names, productions, production companies etc.

We need to design a database that can cross-referance between tables (think imdb), so that, lets say, if you were to select a ”Person” object you would be able to get a referance to every production this person worked on and which role they had. Again, think imdb if that helps.

We feel pretty confident about doing this with different tables in an SQL database, but we’re not to implement at persistance layer until the 2. iteration.

Our instructor has said that we need to design our domain/business layer first, with objects and make the database ”follow suit”.

So my question is: How do we design objects and classes that cross referance each other in this way?

答案1

得分: 0

你可能会想象你的数据库表是 person、film 和 crew_member。crew_member 是连接特定人员与特定影片的关联表。

在 Java 中,领域设计可能如下所示。

class Person
{
    String name;
}

class Film
{
    String title;
}

class CrewMember
{
    Person person;
    Film film;
    String role;
}
英文:

You might imagine your database tables are person, film and crew_member. crew_member is your join table that links a given person with a given film.

The domain design in Java might be as follows.

class Person
{
    String name;
}

class Film
{
    String title;
}

class CrewMember
{
    Person person;
    Film film;
    String role;
}

huangapple
  • 本文由 发表于 2020年4月9日 02:14:26
  • 转载请务必保留本文链接:https://java.coder-hub.com/61107305.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定