Azure Data Studio Tutorial

  Рет қаралды 3,778

Database Star

Database Star

Күн бұрын

Пікірлер: 7
@hellohello-dy5nw
@hellohello-dy5nw 3 ай бұрын
Hi, trying my luck here because I've been stuck at this seemingly trivial problem. I love the simplicity you bring in your videos and hope you can shed some light on my issue. I am trying to design a database for the following requirements: 1. A Station can have 0 to N Webcams. 2. An Equipment can have 0 to N Webcams. 3. An Operator can have 0 to N Webcams. 4. A Webcam can only belong to 1 Station, Equipment or Operator. How can I capture this requirement in my database? ChatGPT gave me 3 options: Polymorphic association (having "related_id" and "related_type" columns), Nullable foreign key fields with CHECK constraints (webcam table with equipment, station and operator FK fields) and seperate tables for each webcam type (StationWebcam, EquipmentWebcam, OperatorWebcam). I understand they all have their pros and cons, but generally speaking, which option would you personally recommend for this particular use case? Thank you in advance!
@DatabaseStar
@DatabaseStar 3 ай бұрын
Good question! This is a problem I've seen and the options you've suggested could all work, but have their pros and cons as you mentioned. I would probably create a new table that's like a "parent" of each of the station/equipment/operator tables. This would have a PK and also an FK to the Webcam. Let's call this table "device" (you would probably be able to come up with a better name). Then, each of the Station, Equipment, and Operator tables would have a FK to this device table. It allows the restrcition of one webcam per device type, and also allows for separate tables. This is a great topic for me to create a video on - I'll do this soon!
@hellohello-dy5nw
@hellohello-dy5nw 3 ай бұрын
@@DatabaseStar Hey Ben, thanks for taking the time to answer! In your suggestion, I am struggling to see how each station, equipment or operator can have multiple webcams, due to the FK to the Webcam table existing in the "Device" table. It seems that this setup can only support each station, equipment or operator to only have a single webcam. To paint a better picture of the requirements, imagine a manufacturing factory floor where a physical station (e.g. Assembly Station), an Equipment (e.g. an Oven) and an Operator (e.g. Bob the Human) can all have webcams attached to them for monitoring purposes. In other words, a station, an equipment or an operator can have 0 to many webcams. A webcam will only be able to exclusively serve 1 station, equipment or operator. I've since found an answer in a StackOverflow thread, where they suggested a similar setup that includes a "supertable". The difference is that this "supertable" will only have a PK, and the Station, Equipment, Operator AND Webcam table will have a FK to the "supertable". I've adapted it a little, but this suits my needs of each station, equipment and operator to have multiple webcams associated to them. Let me know if I'm seeing things differently as compared to your answer. I am looking forward to your video! I had to refine my search terms too many times on Google to finally land on the said StackOverflow thread, so the video will really help beginners like me who are facing similar issues. Thanks! StackOverflow thread link: stackoverflow.com/questions/2002985/mysql-conditional-foreign-key-constraints/2003042#2003042
@tamiratabebe6623
@tamiratabebe6623 3 ай бұрын
thank you ❤❤❤
@DatabaseStar
@DatabaseStar 3 ай бұрын
You're welcome!
@lovetheentertainment9949
@lovetheentertainment9949 3 ай бұрын
Please make courses in udemy
@DatabaseStar
@DatabaseStar 3 ай бұрын
I have several courses on my own website here: www.databasestar.com/course-list/
Azure Data Studio Features in 20 Minutes
18:54
SQLBits
Рет қаралды 38 М.
How to Solve This Database Design Problem
8:09
Database Star
Рет қаралды 1,2 М.
Ice Cream or Surprise Trip Around the World?
00:31
Hungry FAM
Рет қаралды 20 МЛН
How to use Azure SQL Databases | Azure Fundamentals
13:46
Alex The Analyst
Рет қаралды 15 М.
I Tried to Query 10 MILLION Rows in Postgres in 1 Second
14:21
Database Star
Рет қаралды 1,2 М.
40 Advanced Tips for SSMS (To Save You Time)
29:41
Database Star
Рет қаралды 1,4 М.
Easily Import Your Excel File Into SQL Server
4:58
Database Star
Рет қаралды 1,7 М.
Top 5 Time-Saving Extensions in Azure Data Studio
7:05
BI Tracks
Рет қаралды 19 М.
UUID vs INT: What’s Better For Your Primary Key?
9:40
Database Star
Рет қаралды 57 М.
SQL Data Analysis Project: NBA Games & Teams
32:35
Database Star
Рет қаралды 1,4 М.