Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

33%
+0 −2
Q&A How to distinguish between single and multiple file media?

In a media manager I have database tables for files, media and collections. When a user is browsing a collection I want there to be links to see the metadata for single file media like books, movi...

2 answers  ·  posted 2y ago by filosoful‭  ·  last activity 2y ago by r~~‭

Question database
#2: Post edited by user avatar filosoful‭ · 2022-12-15T16:50:17Z (about 2 years ago)
  • In a media manager I have database tables for files, media and collections.
  • When a user is browsing a collection I want there to be links to single file media like books, movies, etc, but there shouldn't be links to multiple file media except for the outmost link. So for example, for games or software, there would be a link to see the game metadata but when you open the game or software folder the rest of the files don't have a link to see the metadata. I would still hash those unimportant files but I don't want to keep metadata like rating, comments, etc for those. How can I make that distinction?
  • These are the tables:
  • ```
  • CREATE TABLE IF NOT EXISTS "media" (
  • "uuid" text(36) NOT NULL PRIMARY KEY,
  • "kind" text NOT NULL, -- file type
  • "rating" real,
  • "comments" integer NOT NULL,
  • "views" integer NOT NULL,
  • "metadata" text NOT NULL, -- duration, width, height, codec, etc
  • "release" text, -- datetime
  • "created" text NOT NULL, -- datetime
  • "updated" text NOT NULL, -- datetime
  • "deleted" integer NOT NULL -- boolean
  • );
  • CREATE TABLE IF NOT EXISTS "file" (
  • "uuid" text(36) NOT NULL PRIMARY KEY,
  • "media_uuid" text(36) NOT NULL,
  • "path" text NOT NULL,
  • "size" integer NOT NULL,
  • "metadata" text NOT NULL, -- json: duration, width, height, codec, etc
  • "indexed" text NOT NULL, -- datetime
  • "updated" text NOT NULL, -- datetime
  • "deleted" integer NOT NULL, -- boolean
  • "parent" text(36), -- for directories
  • "is_directory" integer NOT NULL, -- boolean
  • FOREIGN KEY ("media_uuid") REFERENCES "media" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE
  • );
  • CREATE TABLE IF NOT EXISTS "collection" (
  • "uuid" text(36) NOT NULL PRIMARY KEY,
  • "name" text NOT NULL,
  • "description" text NOT NULL,
  • "owner_uuid" text(36),
  • "rating" real,
  • "views" integer NOT NULL,
  • "created" text NOT NULL, -- datetime
  • "updated" text NOT NULL, -- datetime
  • "deleted" integer NOT NULL, -- datetime
  • FOREIGN KEY ("owner_uuid") REFERENCES "user" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE
  • );
  • ```
  • In a media manager I have database tables for files, media and collections.
  • When a user is browsing a collection I want there to be links to see the metadata for single file media like books, movies, etc, but not for multiple file media. For example, for games or software, there would be a link to see the game metadata but when you open the game or software folder the rest of the files don't have a link to see the metadata. I would still hash those unimportant files but I don't want to keep metadata like rating, comments, etc for those. How can I make that distinction?
  • These are the tables:
  • ```
  • CREATE TABLE IF NOT EXISTS "media" (
  • "uuid" text(36) NOT NULL PRIMARY KEY,
  • "kind" text NOT NULL, -- file type
  • "rating" real,
  • "comments" integer NOT NULL,
  • "views" integer NOT NULL,
  • "metadata" text NOT NULL, -- duration, width, height, codec, etc
  • "release" text, -- datetime
  • "created" text NOT NULL, -- datetime
  • "updated" text NOT NULL, -- datetime
  • "deleted" integer NOT NULL -- boolean
  • );
  • CREATE TABLE IF NOT EXISTS "file" (
  • "uuid" text(36) NOT NULL PRIMARY KEY,
  • "media_uuid" text(36) NOT NULL,
  • "path" text NOT NULL,
  • "size" integer NOT NULL,
  • "metadata" text NOT NULL, -- json: duration, width, height, codec, etc
  • "indexed" text NOT NULL, -- datetime
  • "updated" text NOT NULL, -- datetime
  • "deleted" integer NOT NULL, -- boolean
  • "parent" text(36), -- for directories
  • "is_directory" integer NOT NULL, -- boolean
  • FOREIGN KEY ("media_uuid") REFERENCES "media" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE
  • );
  • CREATE TABLE IF NOT EXISTS "collection" (
  • "uuid" text(36) NOT NULL PRIMARY KEY,
  • "name" text NOT NULL,
  • "description" text NOT NULL,
  • "owner_uuid" text(36),
  • "rating" real,
  • "views" integer NOT NULL,
  • "created" text NOT NULL, -- datetime
  • "updated" text NOT NULL, -- datetime
  • "deleted" integer NOT NULL, -- datetime
  • FOREIGN KEY ("owner_uuid") REFERENCES "user" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE
  • );
  • ```
#1: Initial revision by user avatar filosoful‭ · 2022-12-15T16:46:15Z (about 2 years ago)
How to distinguish between single and multiple file media?
In a media manager I have database tables for files, media and collections.

When a user is browsing a collection I want there to be links to single file media like books, movies, etc, but there shouldn't be links to multiple file media except for the outmost link. So for example, for games or software, there would be a link to see the game metadata but when you open the game or software folder the rest of the files don't have a link to see the metadata. I would still hash those unimportant files but I don't want to keep metadata like rating, comments, etc for those. How can I make that distinction?

These are the tables:
```
CREATE TABLE IF NOT EXISTS "media" (
    "uuid" text(36) NOT NULL PRIMARY KEY,
    "kind" text NOT NULL, -- file type
    "rating" real,
    "comments" integer NOT NULL,
    "views" integer NOT NULL,
    "metadata" text NOT NULL, -- duration, width, height, codec, etc
    "release" text, -- datetime
    "created" text NOT NULL, -- datetime
    "updated" text NOT NULL, -- datetime
    "deleted" integer NOT NULL -- boolean
);


CREATE TABLE IF NOT EXISTS "file" (
    "uuid" text(36) NOT NULL PRIMARY KEY,
    "media_uuid" text(36) NOT NULL,
    "path" text NOT NULL,
    "size" integer NOT NULL,
    "metadata" text NOT NULL, -- json: duration, width, height, codec, etc
    "indexed" text NOT NULL, -- datetime
    "updated" text NOT NULL, -- datetime
    "deleted" integer NOT NULL, -- boolean
    "parent" text(36), -- for directories
    "is_directory" integer NOT NULL, -- boolean
    FOREIGN KEY ("media_uuid") REFERENCES "media" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE
);

CREATE TABLE IF NOT EXISTS "collection" (
    "uuid" text(36) NOT NULL PRIMARY KEY,
    "name" text NOT NULL,
    "description" text NOT NULL,
    "owner_uuid" text(36),
    "rating" real,
    "views" integer NOT NULL,
    "created" text NOT NULL, -- datetime
    "updated" text NOT NULL, -- datetime
    "deleted" integer NOT NULL, -- datetime
    FOREIGN KEY ("owner_uuid") REFERENCES "user" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE
);
```