New DB Structure for all libraries + DBs [update 2015 06 13 / Released SQL 1.3] - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93) +--- Thread: New DB Structure for all libraries + DBs [update 2015 06 13 / Released SQL 1.3] (/showthread.php?tid=200911) |
RE: New DB Structure for all libraries + DBs [update 2014 09 07] - da-anda - 2014-09-10 who said that the API has to work with asset IDs? It could also use the unique IDs for the related file record and send info duplicated (backwards compatible), so we would be just where we are now. But let's not focus on APIs here - let's first get a clean and sensible DB layout. And such a drastic change in DB structure will in any way break backwards compatibility of APIs up to a certain degree - at least if client wants to use the new features. There could be a compat mode Kodi side though. RE: New DB Structure for all libraries + DBs [update 2014 09 07] - Tolriq - 2014-09-10 Who said I talked only about API ? (Was only an easy sample) I only try to remember all the usages currently and future (synchronization, profiles) so they are not forgotten during the db layout. As I said already you can't build a layout without knowing all the targets that it must cover if you want to avoid hacks at some future steps when finally a "oups we forget this happens". Things easy to forget when not thinking large enough, profiles and permissions. If you set permissions on asset, what about kids profiles having access to an unrated version of a movie with scene that are not suitable for them ? (And it's only a very simple thing, there's plenty to think of to achieve the correct goal) Seeing a layout being built here with tons of different point of view, without a validated target will be source of problems. Now you can ignore my advice I will not be blessed but at least I tried RE: New DB Structure for all libraries + DBs [update 2014 09 07] - spcano01 - 2014-09-10 Gotta agree that new DB is needed, even at expense of duplicate copies/versions of same movie. Make it two movies, or two versions of same movie...don't really care. I don't want TOO much "required" that this doesn't move forward with what has been discussed already. It's already a HUGE improvement over existing, and if we can handle that - I'm sure we can add future functionality easier as well. Not to be confused with going at this half-assed...just saying that we can always find a reason NOT to do something. I would love the idea of PLEX, but really couldn't figure out how to get it up and running. Tried multiple times with homebuilt NAS and Synology one. But the XBMC DB just works, and I love the XBMC itself. My 2 pesos... (2014-09-10, 09:52)pecinko Wrote:(2014-07-29, 19:09)m.savazzi Wrote: The original point was to have the possibility of using different DB servers as shared library among different XBMC. RE: New DB Structure for all libraries + DBs [update 2014 09 07] - phate89 - 2014-09-13 There is another wrong relationship. A file could be more than one episode. For example: Lost.S01E01-02 In this case the file is both lost season 1 ep 1 and lost season 1 ep 2 RE: New DB Structure for all libraries + DBs [update 2014 09 07] - m.savazzi - 2014-09-13 (2014-09-09, 07:57)Montellese Wrote:(2014-09-08, 20:40)phate89 Wrote: But in this way don't you have 2 times the movie in the database with all scraped info with 2 different ids? Correct and this is NOT the case. Director's cut and Theatrical are TWO different movies, they have different poster, etc... They have different Runtime, different Year, etc... The IMDB ID is different. On the other side is true that they share a set of common information like Artists, director, etc... What I mean to write is that the DB Structure is smart enough to handle this situation avoding duplicated info. (2014-09-09, 07:57)Montellese Wrote: I'm actually working on this with the current DB layout and I added a table that links files to media items and during library scanning it detects "identical media items" (for movies it uses the title and year or imdbid). Then when retrieving all movies you get an item for every version of a media item (with the identical database ID and the identical metadata but with different file details like streams) which you can easily go through and put together all items with the same database ID (no additional complex logic that slows down the listing necessary) into a single item that is then presented like a movie set Good. In the new DB we can do the same using the Version table so we avoid duplications. Example: Version 1 of movie Foo: foo - part 1.mpg foo - part 2.mpg Version 2 of movei foo: foo.mkv In this way we will have File 1: foo - part 1.mpg File 2: foo - part 2.mpg File 3: foo.mkv Asset 1: foo bound to file 1, file 2 Asset 2: foo bound to file 3 Version table: asset 2 bound to asset 1 So we will NOT duplicate common information on 2 as we already have one. On 2 we will add the video and audio track info. (2014-09-08, 20:40)phate89 Wrote: Also about the watched status i think should be related to the episode, movie etc etc. It's the episode/movie itself that i watched not the specific file. If i have 2 versions of the file and i watch the first the 2nd should also result watched. Also if you remove a watched episode or movie and then you add it back the asset will be deleted and created so the episode will result unwatched, however since the episode entry won't be deleted the database will already have the watched status. (2014-09-08, 22:17)m.savazzi Wrote: At program level you can simply add the details to the first version and copy them to the other or even not copy just leave the second record empty IMO this is something that should be definable by the user i.e. the user should be able to choose whether watching the standard version of movie X should also mark the director's cut version of the same movie X as watched or not. Therefore it should be linked to the specific file and xbmc/kodi can implement the necessary logic to do it the way the user wants. That "freedom" is not possible if the watched status is linked to the media item / asset. [/quote] Not correct. As explained in the example we will have Asset 1: foo Asset 2: foo Version table: asset 2 bound to asset 1 If user wants to have separate view state in the AssetViewed table you will havbe Asset 1: viewed true Asset 2: viewed false If you want to have a single viewed state there are 2 options either when you update the viewed state you use the Version table to update all status at once OR you use only viewed 1 to update AND you use version table to retrieve Always asset 1 status when querying. I like more the first as if user decides to switch from one mode (all the same) to the other (each asset it's viewe state) the user experience is better. It's a freedom for Kodi code. (2014-09-09, 11:08)phate89 Wrote:(2014-09-09, 07:57)Montellese Wrote: IMO this is something that should be definable by the user i.e. the user should be able to choose whether watching the standard version of movie X should also mark the director's cut version of the same movie X as watched or not. Therefore it should be linked to the specific file and xbmc/kodi can implement the necessary logic to do it the way the user wants. That "freedom" is not possible if the watched status is linked to the media item / asset. (2014-09-09, 11:27)Tolriq Wrote: Do not forget that the final plan is synchronization. This is why I wrote in post 1 that the files are identified via the CRC32! this is independent from the file name BUT is very time/disk consuming if the OS is not able to provide it on the fly. Otherwise we should rely on file name. There could NOT be multiple database ID for the SAME file. It's a nonsense and an error at Kodi level. If I rename a file it old File x record should be removed OR (if possible) Updated. (2014-09-09, 11:27)Tolriq Wrote: Have not yet check the db proposal, but files / path or anything should be the object linked to physical details and description ... And we could use some kinds of collations to link the movies together like sets. Please check the DB as this is very well addressed (2014-09-09, 14:02)jjd-uk Wrote: The support of multiple versions of one media item is certainly coming, as it's absolutely necessary for Montellese work in allowing media from multiple sources being added to the Library. For example you might have the same movie in: Correct is the Version table that binds the three assets. At this point Kodi is free to show them as the user likes. They can be shown as three movies, as one folder with three assets as three episodes... it's up to Kodi. The DB will simply have all the correct info (with no, or minimal duplicated info) and very easy ways to recover them (2014-09-09, 14:36)phate89 Wrote: Is it the best way to handle them as movie sets? In any view available you will have 3 items with same artwork, same title and only different stream details. Very confusing and not very immediate IMO.. The DB allow Kodi code and the user to decide what to do. Using version table you have a lot of freedom for example you can decide that Asset 1 will have poster, fanart and all other info and all other Assets versions will not have any info OR you can decide that Asset 1 are the defaults for all versions BUT a version can have a different fanart OR you can decide that each version will have it's own set of details. As said the DB supports all of this in an easy way. Kodi should decide how to interact with the user. (2014-09-09, 15:35)Fice Wrote: I think we should store additional information in the link from a file to an asset, as we have three situations where one movie might have several files. Using CRC32 there will not be 2 files/assets as they are the same Using filename there could be 2 entries and the user or some Kodi logic should bind them together with the versions table. They can be "local" and "remote" (2014-09-09, 15:35)Fice Wrote: B) If we have to different versions (uncut versus directors cut) then we should probably show them as a set and if one version is watched, doesn't mean we should automatically mark the other as watched as well (perhabs make it a setting). (The link from file to asset could probbly contain some metadata that is likely to differ: duration/PG rating/Year?!?) explained before how it works. All possible scenarios fully supported. (2014-09-09, 15:35)Fice Wrote: C) The same movie, the same version but different qualites. Is there a need for the user to select the qualities? Just play the highest quality the device can play. Would a user actually prefer SD over a HD? Not sure about 3D vs. non 3D version though. (Don't have a 3D tv) As above, fully supported. RE: New DB Structure for all libraries + DBs [update 2014 09 07] - phate89 - 2014-09-13 edit: still answering RE: New DB Structure for all libraries + DBs [update 2014 09 07] - m.savazzi - 2014-09-13 (2014-09-09, 16:33)phate89 Wrote:(2014-09-09, 15:35)Fice Wrote: C) The same movie, the same version but different qualites. Is there a need for the user to select the qualities? Just play the highest quality the device can play. Would a user actually prefer SD over a HD? Not sure about 3D vs. non 3D version though. (Don't have a 3D tv) Yes, fully supported as explained in previous example. (2014-09-09, 19:36)Tolriq Wrote: Same problem for remotes Tags table is bound to Assets. If you add tags you can do filtes on that. It's another level of freedom. (2014-09-10, 06:58)garbear Wrote:(2014-08-30, 12:13)m.savazzi Wrote: Requests: Great! Will add them in the DB and the save state (2014-09-10, 13:07)Tolriq Wrote: The choice about 1 ID per real media or 1 ID by meta data is a db layout issue and this choice impact all the rest. Asset ID IS the unique media id. An asset CAN be composed by different files (movie foo - part 1, movie foo - part 2) File ID is unique per physical asset (independently is if local, remote, UPnP, web, etc) So we have no issues there. (2014-09-13, 01:39)phate89 Wrote: There is another wrong relationship. The DB fully supports this In this case the structure will be: File 1: Lost.S01E01-02 Asset 1: Lost Series 1 Episode 1 bound to File 1 Asset 2: Lost Series 1 Episode 2 bound to File 1 Quite straight forward. RE: New DB Structure for all libraries + DBs [update 2014 09 07] - phate89 - 2014-09-13 (2014-09-13, 11:30)m.savazzi Wrote: Correct and this is NOT the case. Director's cut and Theatrical are TWO different movies, they have different poster, etc... They have different Runtime, different Year, etc...It's not true. First of all they have the same imdb id: http://www.imdb.com/title/tt1411250/?ref_=nv_sr_1 as you can see same id SAME MOVIE 2 different lengths. You can't say director's cut is a different movie. It's just wrong. It's the same movie..Often it's even in the same bluray and they share 90% of the video. It's only a different version of it. It's a big design flaw to let the same movie twice in the db... (2014-09-13, 11:41)m.savazzi Wrote: The DB fully supports this Not according to the graph. You have an asset that can have more than one file. One to many. Not the opposite.. RE: New DB Structure for all libraries + DBs [update 2014 09 07] - m.savazzi - 2014-09-13 (2014-09-13, 11:40)phate89 Wrote:(2014-09-13, 11:30)m.savazzi Wrote: Correct and this is NOT the case. Director's cut and Theatrical are TWO different movies, they have different poster, etc... They have different Runtime, different Year, etc...It's not true. Can you help me on IMDB. I'm not able to find the "normal" and the "director's cut" it just shows me the "normal" version. With regards to being 2 movies is quite easy: if original movie is 120 min and directors cut is 150 min... they are different. Also they have different votes, rating, MPAA, etc... They are SOLD as two different movies, they have 2 different ISRC codes... etc... If you check what I wrote there are NO duplications (or minimal) in case you save them as two assets so there is not a design flaw (2014-09-13, 11:50)phate89 Wrote:(2014-09-13, 11:41)m.savazzi Wrote: The DB fully supports this No is a M:N relationship. One File can be bound to muliple Assets: case where one file is two episodes OR if you have an ISO where there are multiple movies (I have plenty) One File can be bound to one Assets: easy case Multiple File can be bound to One Assets: is a multipart movie/episode. The structure MUST cover all this scenarios in the correct way.... and it does RE: New DB Structure for all libraries + DBs [update 2014 09 07] - phate89 - 2014-09-13 (2014-09-13, 11:51)m.savazzi Wrote: Can you help me on IMDB. I'm not able to find the "normal" and the "director's cut" it just shows me the "normal" version.It's not true. Actually most of blurays contains both versions. It's quite easy with bluray you split the movie into segments and have 2 different playlist combining the parts in common and the different parts. It's called seamless branching. In a bright future this could be achievable even with mkv and stacked files so you will have 2 versions of the same movie (director's and theatrical) in the same mkv file with almost the same size of a single movie (actually if we want to think very wide we should also consider this possibility) 2nd thing there are no different votes, rating, mpaa. They are the same movie. I didn't pass you the theatrical cut version. I passed the only version there is of that movie. if you open that link and go to look to the movie length you get: Technical Specs Runtime: 119 min | 127 min (director's cut) There is no separate version. It's always the same movie with a different length. OF course if they are sold separately they have a different code but also dvd->bluray version have different code, remastered has a different code. I lost count of how many star wars different versions went out. 6? 7? But we still consider them the same movie in all these cases. (2014-09-13, 11:51)m.savazzi Wrote: No I'm looking to your pdf and the relationship from asset to files is one to many RE: New DB Structure for all libraries + DBs [update 2014 09 07] - m.savazzi - 2014-09-13 (2014-09-13, 11:59)phate89 Wrote:(2014-09-13, 11:51)m.savazzi Wrote: Can you help me on IMDB. I'm not able to find the "normal" and the "director's cut" it just shows me the "normal" version.It's not true. Well for me if a movei has diferent Runtime is a different movie... but I'm ok with your view. The DB supports it with no issue with 2 assets. I think I have more than 15 Star wars (original) copies between VHS, SCD, DVD, Bluray, etc... (2014-09-13, 11:51)m.savazzi Wrote: No I'm looking to your pdf and the relationship from asset to files is one to many [/quote] Sorry, it's a mistake in the schema! Will update it! New DB Structure for all libraries + DBs [update 2014 09 07] - phate89 - 2014-09-13 (2014-09-13, 13:13)m.savazzi Wrote: Well for me if a movei has diferent Runtime is a different movie... but I'm ok with your view.But that'S a flaw in the design that will cause inconsistency and makes harder to obtain movies only. It's not hard to split assets from movies and prevent that kind of duplication leaving the different tag (like duration) to the asset or the file. Also this kind of separation is needed for montellese's work (just like the "sources" folder that is still missing) so it needs to be in the db. In this case in montellese's work you have everytime to group to find out if a movie is already in the database and it's not efficient. Also it will create inconsistency. Same movie, different art, different plot, different rating and even different genre is possible. Why the asset have to be the movie? They are 2 different things so they should be separate in db to bring easier access and remove inconsistencies RE: New DB Structure for all libraries + DBs [update 2014 09 07] - m.savazzi - 2014-09-13 (2014-09-13, 13:25)phate89 Wrote:(2014-09-13, 13:13)m.savazzi Wrote: Well for me if a movei has diferent Runtime is a different movie... but I'm ok with your view.But that'S a flaw in the design that will cause inconsistency and makes harder to obtain movies only. It's not hard to split assets from movies and prevent that kind of duplication leaving the different tag (like duration) to the asset or the file. There is now flaw. It's very simple: Asset 1: Riddick (Title: Riddick, Duration 119) Asset 2: Riddick (Director's Cut) (Title: Riddick Director's Cut, Duration 125) Version will bind asset 1 and asset 2 In this way you can have (if you want) different fanart for Riddick and Director's cut. As said this is the most flexible way. (2014-09-13, 13:25)phate89 Wrote: Also this kind of separation is needed for montellese's work (just like the "sources" folder that is still missing) so it needs to be in the db. In this case in montellese's work you have everytime to group to find out if a movie is already in the database and it's not efficient. Also it will create inconsistency. I already asked to provide me examples of sources and paths but have not received them. Is not clear to me. With the info I have and understanding I have the DB is fine in all scenarios... can you help me understand with examples? Let's make it like: File 1: path: filename: source: extension: descritpion: library: File 2: path: filename: source: extension: descritpion: library: ... File n: path: filename: source: extension: descritpion: library: so you can give me all possible cases and I will see if the DB is fine or need to be changed can you explan better this "you have everytime to group to find out if a movie is already in the database" is not clear to me. There is no "grouping" needed- (2014-09-13, 13:25)phate89 Wrote: Same movie, different art, different plot, different rating and even different genre is possible. No this is not possible, and also Director's cut is not the same movie of the Theatrical. I want to have a different poster, different fanart for them. If you do not want to use that functionality you can simply use the case where Asset 1 is the default for all. (2014-09-13, 13:25)phate89 Wrote: Why the asset have to be the movie? They are 2 different things so they should be separate in db to bring easier access and remove inconsistencies Asset is the parent of movie. An asset can be a movie, an episode, a game, a fanart, a game, a picture... etc... I think you made a little confusion on that. RE: New DB Structure for all libraries + DBs [update 2014 09 07] - phate89 - 2014-09-13 Again it doesn't matter what is the path and what is the file name. Kodi needs to store somewhere if the user wants to automatically import media from a specific kodi instance or not. If you have 3 other kodi pcs in your network and you want to automatically import from "k1" only movies, from "k2" only music and import nothing from "k3" you need a table to store it where kodi will look. Something like: Code: id getmovie getmusic k2 tells my kodi it has 4 new movies and 1 new song? Ok i search in sources k2. IT only wants music so i only import the new song. k3 tells my kodi it has 2 new movies and 5 new songs? Ok i search in sources k3. It wants nothing from k3 so it will not add any movie or song. There is a new kodi pc called "k4" that has 4 movies and 10 songs? Kodi search in the sources database but there is no "k1". So kodi will ask the user what he wants to do with the new one and store it in "sources" table so the next time it will know how to behave. You are Italian right? If you are I can explain it in Italian so maybe we understand each other better. Btw theatrical IS the same movie of director's. You can look everywhere and it's always one movie. Maybe they split it in versions or something else but is still logically a unique thing with eventually 2 child items. It will always have same main title, same plot, same genre, same rating between all versions and you need consistency between them and make it easy to access. Also you know it's the same thing intrinsically, you just don't realize it.You call the relationship between asset1 and asset2 Version. But they are versions of what? Versions of a movie, of an episode etc etc.. Why you need an external relationship when you can place that "version" or "asset" or something else between file and movie? A movie can have more than one version/asset (separated by a specific tag or a specific name that could be "theatrical", "directors" or even "sd", "hd"). The version can have one or more files. So the movie will have the intrinsics that define what a movie is and are common between them to have consistency like title, imdb id, plot, rating, genres. The version/asset will have what defines a new version. Length, version name. File will contain all files specific info. Also this will allow to connect the same asset/version to both an episode and a movie (for example "serenity" is both an extra episode of "firefly" and a movie) without duplicate info and for smart playlist it will be available the same asset/version for both tv episodes and movies and not 2 different one. Same thing with mixed playlist. In your model if you do a mixed smart playlist you will have 2 times the same file because there are 2 assets. But with a single asset you will have it only once. The grouping part is because kodi after montellese's changes will show a list of movies and not anymore the list of "assets" to tackle duplicates. With upnp sharing it will be possible to have even 3/4 versions of the same movie in case all upnp instances has that so instead to have 4 times the same movie you will have once the movie and when you play it will ask what version to play. A lot better IMO even logically. With separate movie/episode tables is quite easy to achieve this or even if you want the old method. You only get them with a simple select. But with your method to have a list of movies without duplicates you have to group by title and imdb id everytime you load the movie list / episode list (what montellese defined as same movie and uses to search it). Also in case of director's cut -> theatrical cut you won't be able to group them because they have different title so you will have always no matter what in 2 separate items. (2014-09-13, 14:25)m.savazzi Wrote: Asset is the parent of movie. An asset can be a movie, an episode, a game, a fanart, a game, a picture... etc...I understand this. But why 2 asset can't be the same movie? why 2 assets can't be the same episode? Also do not forget that an asset can be both a movie and an episode at the same time like i said before. Asset and movies should be separated to avoid inconsistencies, dupicate infos and allow to link to each other.. RE: New DB Structure for all libraries + DBs [update 2014 09 07] - pecinko - 2014-09-13 (2014-09-13, 15:26)phate89 Wrote: Again it doesn't matter what is the path and what is the file name. Kodi needs to store somewhere if the user wants to automatically import media from a specific kodi instance or not. If you have 3 other kodi pcs in your network and you want to automatically import from "k1" only movies, from "k2" only music and import nothing from "k3" you need a table to store it where kodi will look. Something like: Common, you are either interested in "network kodis" or not. Thus, simple "Include network instances" setting should suffice. How would settings screen look like in your example? You have 3 Kodi instances and each can have X library sections - as you can split movies/music/pictures as a separate library sections like documentaries, comedies, home, vacation, classic etc If theatrical is the same as director's cut why would you have both of them and not just one? I can see the reasoning in having sd/hd/3d versions of the same movie but let's not put everything with a similar name into this category. |