Skip to content
Advertisement

Tag: database-design

How to add a column default?

I created a Postgres DB which contains 5 tables. Then I realized that the column student.student_id lacks a column default to generate an UUID: Knowing that some tables are linked to the student table, how can I add to the function as column default for student_id so that the result will be: Answer Use ALTER TABLE: Column defaults do not

Data Model for multiple checkboxes

I currently have a supplier table and now I want to store the regions served by each supplier. As a first thought, I made my supplier model like this : Does this seem to be a good pattern? Especially for queries to filter suppliers by region served etc. Is this solution still reliable if in the future I want to

How to decompose the tables for optimal querying

Suppose I have three tables Actor, Movie, Producer with following attributes Actor(Id,ActorName,Bio) Producer(Id,ProducerName,Bio) Movie(Id,Name,Description,ActorName,ProducerName) There can be many actors in a movie and actor can act many movies, same goes with producer. How to effectively decompose/create new tables to store data. I tried creating a new table with following schema ActorMovie(Id, MovieId, ActorId) but failed as there can be multiple

designing a follower/following schema between two tables in SQL?

suppose we have two tables: Brands Users i want to design a system where: Brands can follow Brands Brands can follow Users Users can follow Brands Users can follow Users this is what i have done so far: ed_id: user_id of the followed er_id: user_id of the follower note: the two tables are different but i haven’t written all the

Advertisement