-2

I am creating a website that allows to teachers to uploading courses, what's better, to just use the DB or should I use storage services, and how could I know the size of the videos?

I am using AWS if the services better, please give me a service name.

1
  • Storage services will be the better choice,DB will make your process slow
    – Ishan Shah
    Dec 29 '20 at 9:37
0

Making Relational Databases Work

Database storage is ideal, but in practice not easy to do correctly.

Most relational Databases (like MySQL) are not well suited to storing binary files. In fact, many don't work well even with 64KB blobs. Normalisation of a schema reduces the size of rows (and increases the amount of tables to spread out locking) so that scanning of records is faster. Large blobs slow this down.

For this reason, any file storage within a relational database should be normalised to an additional table separate to all of the other fields. For example:

  • UserVideos - ID, UserVideoFileID, UserID, VideoTitle, VideoDescription, Tags, etc...
  • UserVideoFiles - ID, UserVideoFileBlobID, UploadedFileName, FileSize, MIME, Extension, VideoCodec, AudioCodec
  • UserVideoFileBlobs - ID, Blob

With the right database system, you should be able to store the UserVideoFileBlobs table in a separate Database File, with a specialised backup regimin. You can also partition. MySQL might have a suitable file storage engine (I don't think so).

Files

Instead of UserVideoFileBlobs, you might instead of File Storage or Cloud Blob storage (like S3). File storage is quite ideal, because you can also make it directly downloadable via HTTP alleviating load on your database.

In between

Sqlite seems to brag about being better at storing files than a file system. But backups are probably still challenging. You might use multiple sqlite files as you might normally use file folders

Recommendation - S3.

2
  • 1
    Isn't that already how relational databases store blobs? AFAIK, most of them create a secret "blobs" table and just store the ID of the blob in the main table
    – user253751
    Dec 29 '20 at 18:35
  • @user253751 Sort of. In any case, if it's "hidden" it isn't as configurable. A literal table UserVideoFileBlobs lets you adjust the backing storage; it also means that the client can select UserViewFiles without accidentally downloading all of the blobs. Dec 30 '20 at 1:33
0

Save the video to S3, and save its location in your database. S3 will be cheaper and is designed for file storage, plus will be easier to embed in webpages. For the video size question, an s3 api call will tell give you that, which you could store in your database (if you don't need a relational database for other purposes, you could use DynamoDB here).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.