Answer the question
In order to leave comments, you need to log in
Database design for a filmo database site?
The question is tormenting, even a few about the database for the movie site ala imdb.
Now I plan to shove all videos (movie, series) into 1 table with a type label.
All the actors, the team (director, screenwriter, etc.) should be
shoved into 1 table film_person
id
movie_id
person_id
role_id (actor / director / make-up artist / ..)
name (only for actors and maybe if the narrow specialty of the team
member ) no and saw that themiviedb has separate. entities for films and series. And separately. entities for linking film_cast, film_crew
Ancient database script imdbimport separate film_cast for shows, movies, episodes of series.
Approximate number of films/series 1m
What do you think about this? Should I separate or shove as I originally intended?
Answer the question
In order to leave comments, you need to log in
as for the types of films - it all depends on what information about the films you will store.
For example: a series may have information about the number of seasons, about the number of episodes in a season, but a movie does not have such information. Therefore, in my opinion, it is more optimal to store either each type of film in a separate table, or create a general table "Films" and create a separate table with "features" for each type. This will make the system more scalable.
As for the persons - if there is no plan to store any general information about the team - your option is quite appropriate, but it should be borne in mind that one person can be an actor in one film, a producer in another, and both an actor and producer at the same time in the third.
Due to the large number of relationships between entities (strong coupling), you will have to perform complex queries with several JOINs, so it makes sense to build a database based on graph databases, such as ArangoDB, Neo4j.
Slides:
Neo4j Graph Database: Introduction and Simple Example
ArangoDB – A different approach to NoSQL
Now I plan to shove all videos (movie, series) into 1 table with a type label.
CREATE TABLE [Film](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Heading] [int] NULL,
[HeadingName] [varchar](20) NULL,
[HeadingClose] [bit] NULL,
[SeriesName] [varchar](15) NULL,
[Series] [smallint] NULL,
[SeriesDigit] [smallint] NULL,
[Season] [smallint] NULL,
[Episode] [smallint] NULL,
[PartName] [varchar](15) NULL,
[Part] [smallint] NULL,
[HeadingNumber] AS (isnull(isnull([SeriesName]+' ','серия ')+CONVERT([varchar],[Series]),'')+isnull((('s'+right('00'+CONVERT([varchar],[Season]),(2)))+'e')+right('00'+CONVERT([varchar],[Episode]),(2)),'')),
[Serias] [smallint] NULL,
[Article] [varchar](20) NULL,
[Name] [varchar](200) NULL,
[NameTranslat] [varchar](200) NULL,
[Year] [smallint] NULL,
[Premiere] [smalldatetime] NULL,
[Country] [varchar](50) NULL,
[Addition] [varchar](200) NULL,
[TitleArticleLess] AS ((([Name]+isnull((' ('+[NameTranslat])+')',''))+isnull((' ['+[Addition])+']',''))+isnull(((', '+isnull([PartName],'часть'))+' ')+CONVERT([varchar],[Part]),'')),
[TitleBase] AS ((((isnull([Article]+' ','')+[Name])+isnull((' ('+[NameTranslat])+')',''))+isnull((' ['+[Addition])+']',''))+isnull(((', '+isnull([PartName],'часть'))+' ')+CONVERT([varchar],[Part]),'')),
[TitleYear] AS (((((isnull([Article]+' ','')+[Name])+isnull((' ('+[NameTranslat])+')',''))+isnull((' ['+[Addition])+']',''))+isnull(((', '+isnull([PartName],'часть'))+' ')+CONVERT([varchar],[Part]),''))+isnull(' · '+CONVERT([varchar],[Year],(104)),'')),
[TitleCountry] AS (((((isnull([Article]+' ','')+[Name])+isnull((' ('+[NameTranslat])+')',''))+isnull((' ['+[Addition])+']',''))+isnull(((', '+isnull([PartName],'часть'))+' ')+CONVERT([varchar],[Part]),''))+isnull(' · '+[Country],'')),
[TitleYearCountry] AS ((((((isnull([Article]+' ','')+[Name])+isnull((' ('+[NameTranslat])+')',''))+isnull((' ['+[Addition])+']',''))+isnull(((', '+isnull([PartName],'часть'))+' ')+CONVERT([varchar],[Part]),''))+isnull(' · '+CONVERT([varchar],[Year],(104)),''))+isnull(' · '+[Country],'')),
[Cover] [image] NULL,
[Note] [text] NULL,
[NotWatch] [bit] NULL,
[LastWatch] [datetime] NULL,
[DateWatch] [datetime] NULL,
[WatchDisplay] AS (isnull('+ '+CONVERT([varchar],[DateWatch],(104)),'')+isnull(case when [DateWatch] IS NULL then CONVERT([varchar],[LastWatch],(104)) else (' ('+CONVERT([varchar],[LastWatch],(104)))+')' end,'')),
[Range] AS ((((((isnull(CONVERT([varchar](4),[Year]),'1895')+right('00'+CONVERT([varchar],isnull([Series],(0))),(3)))+right('00'+CONVERT([varchar],isnull([Season],(0))),(3)))+right('00'+CONVERT([varchar],isnull([Episode],(0))),(3)))+isnull(CONVERT([varchar](8),[Premiere],(112)),'00000000'))+right('00'+CONVERT([varchar],isnull([Part],(0))),(3)))+isnull(upper([Name]),'')),
[SearchValue] AS (replace(rtrim([Name]),' ','+')),
[Icon] AS (CONVERT([bit],isnull(datalength([Note]),(0)),(0))+CONVERT([bit],isnull(datalength([Cover]),(0)),(0))*(2)),
[AttributeIcon] [bit] NULL,
CONSTRAINT [PK_Film] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [Film] ADD CONSTRAINT [DF_Film_AttributeIcon] DEFAULT ((0)) FOR [AttributeIcon]
GO
ALTER TABLE [Film] WITH CHECK ADD CONSTRAINT [FK_Film_Film] FOREIGN KEY([Heading])
REFERENCES [dbo].[Film] ([ID])
GO
ALTER TABLE [Film] CHECK CONSTRAINT [FK_Film_Film]
GO
CREATE TABLE [FilmAttributeGroup](
[ID] [smallint] IDENTITY(1,1) NOT NULL,
[Name] [varchar](50) NOT NULL,
[Person] [bit] NULL,
[Under] [bit] NULL,
[Range] [smallint] NOT NULL,
[Uses] [int] NOT NULL,
CONSTRAINT [PK_FilmAttributeGroup] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [FilmAttributeGroup] ADD CONSTRAINT [DF_FilmAttributeGroup_Range] DEFAULT ((0)) FOR [Range]
GO
ALTER TABLE [FilmAttributeGroup] ADD CONSTRAINT [DF_FilmAttributeGroup_Uses] DEFAULT ((0)) FOR [Uses]
GO
CREATE TABLE [FilmAttributeValue](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Group] [smallint] NOT NULL,
[Value] [varchar](300) NOT NULL,
[ValueLeft] AS (rtrim(case when charindex('(',[Value])>(0) then left([Value],charindex('(',[Value])-(1)) else [Value] end)),
[ValueRight] AS (rtrim(case when charindex('(',[Value])>(0) then substring([Value],charindex('(',[Value])+(1),(charindex(')',[Value])-charindex('(',[Value]))-(1)) end)),
[SearchValue] AS (replace(rtrim(case when charindex('(',[Value])>(0) then left([Value],charindex('(',[Value])-(1)) else [Value] end),' ','+')),
[Person] [int] NULL,
[Equalize] [bit] NOT NULL,
[Uses] [int] NULL,
CONSTRAINT [PK_FilmAttributeValue] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [FilmAttributeValue] ADD CONSTRAINT [DF_FilmAttributeValue_Equalize] DEFAULT ((1)) FOR [Equalize]
GO
ALTER TABLE [FilmAttributeValue] WITH CHECK ADD CONSTRAINT [FK_FilmAttributeValue_FilmAttributeGroup] FOREIGN KEY([Group])
REFERENCES [dbo].[FilmAttributeGroup] ([ID])
ON DELETE CASCADE
GO
ALTER TABLE [FilmAttributeValue] CHECK CONSTRAINT [FK_FilmAttributeValue_FilmAttributeGroup]
GO
ALTER TABLE [FilmAttributeValue] WITH CHECK ADD CONSTRAINT [FK_FilmAttributeValue_Person] FOREIGN KEY([Person])
REFERENCES [dbo].[Person] ([ID])
ON DELETE SET NULL
GO
ALTER TABLE [FilmAttributeValue] CHECK CONSTRAINT [FK_FilmAttributeValue_Person]
GO
REATE TABLE [FilmAttribute](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Film] [int] NOT NULL,
[Attribute] [int] NOT NULL,
[Addition] [varchar](250) NULL,
[GroupEdit] [int] NULL,
CONSTRAINT [PK_FilmAttribute] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [FilmAttribute] WITH CHECK ADD CONSTRAINT [FK_FilmAttribute_Film] FOREIGN KEY([Film])
REFERENCES [dbo].[Film] ([ID])
GO
ALTER TABLE [FilmAttribute] CHECK CONSTRAINT [FK_FilmAttribute_Film]
GO
ALTER TABLE [FilmAttribute] WITH CHECK ADD CONSTRAINT [FK_FilmAttribute_FilmAttributeValue] FOREIGN KEY([Attribute])
REFERENCES [dbo].[FilmAttributeValue] ([ID])
GO
ALTER TABLE [FilmAttribute] CHECK CONSTRAINT [FK_FilmAttribute_FilmAttributeValue]
GO
CREATE TABLE [Person](
[ID] [int] IDENTITY(1,1) NOT NULL,
[FirstName] [varchar](100) NULL,
[LastName] [varchar](100) NOT NULL,
[NameRussian] [varchar](200) NULL,
[BirthDay] [smalldatetime] NULL,
[BirthPlace] [varchar](100) NULL,
[DeathDay] [smalldatetime] NULL,
[DeathPlace] [varchar](100) NULL,
[Text] [text] NULL,
[Picture] [image] NULL,
[Uses] [int] NULL,
[NameFull] AS ((isnull([FirstName]+' ','')+ltrim([LastName]))+isnull((' ('+[NameRussian])+')','')),
[NameOrder] AS ((ltrim([LastName])+isnull(', '+[FirstName],''))+isnull((' ('+[NameRussian])+')','')),
[SearchValue] AS (isnull(replace([FirstName],' ','+')+'+','')+replace([LastName],' ','+')),
[NoteIcon] AS (CONVERT([bit],isnull(datalength([Text]),(0)),(0))+CONVERT([bit],isnull(datalength([Picture]),(0)),(0))*(2)),
[Key] AS ('P'+CONVERT([varchar],[ID])),
CONSTRAINT [PK_Performer] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [Person] ADD CONSTRAINT [DF_Person_Uses] DEFAULT ((0)) FOR [Uses]
GO
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question