Can you improve following dimension design for DropBox application? Fact Tables 1.…
- User
Can you improve following dimension design for DropBox application?
Fact Tables
- FactUploads
- UploadID (PK)
- UserID (FK)
- FileID (FK)
- DateKey (FK)
- TimeKey (FK)
- FileSize
- SuccessFlag
- FactShares
- ShareID (PK)
- UserID (FK)
- FileID (FK)
- SharedWithUserID (FK)
- DateKey (FK)
- TimeKey (FK)
- ShareTypeKey (FK)
- SuccessFlag
- FactOwnershipTransfers
- OwnershipTransferID (PK)
- OriginalOwnerUserID (FK)
- NewOwnerUserID (FK)
- FileID (FK)
- DateKey (FK)
- TimeKey (FK)
- SuccessFlag
- FactSubscription
- SubscriptionID (PK)
- UserID (FK)
- DateKey (FK)
- SubscriptionTypeKey (FK)
- Revenue
- FactCustomerSupport
- SupportTicketID (PK)
- UserID (FK)
- DateKey (FK)
- TimeKey (FK)
- IssueTypeKey (FK)
- ResolutionTime
Dimension Tables
- DimUser
- UserID (PK)
- UserName
- UserEmail
- AccountTypeKey (FK)
- DimFile
- FileID (PK)
- FileName
- FileType
- FolderID (FK)
- DimDate
- DateKey (PK)
- Date
- Weekday
- Month
- Quarter
- Year
- DimTime
- TimeKey (PK)
- Time
- Hour
- Minute
- DimAccountType
- AccountTypeKey (PK)
- AccountTypeName
- DimFolder
- FolderID (PK)
- FolderName
- ParentFolderID (FK)
- DimShareType
- ShareTypeKey (PK)
- ShareTypeName (e.g., link, direct, group)
- Assistant
- User
Create Alter script to add your improvement.
- Assistant
- User
need creation script for DimTransferReason, DimSeverityLevel, DimResolutionStatus
- Assistant
- User
Based on your latest change, answer following question: SQL question - Find how many users only upload photos?
- Assistant
To answer this question, you need to make some assumptions around what constitutes a "photo" in Dropbox. This could rely on file type extensions (like
.jpg,.png, etc.) or could be a defined attribute in theDimFiletable. Assuming there is a column namedFileTypethat includes the file extension, you can query the dataset to count how many users have only uploaded files with photo extensions. - User
SQL question - how many files have multiple owners;
- Assistant
To find out how many files have multiple owners, we'll query the
FactOwnershipTransfersfact table and count the file IDs that appear more than once in that table, indicating that ownership has been transferred between different users at least once.Here's an SQL query that accomplishes this:
SELECT COUNT(*) AS FilesWithMultipleOwners FROM ( SELECT FileID FROM FactOwnershipTransfers GROUP BY FileID HAVING COUNT(DISTINCT NewOwnerUserID) > 1 ) AS MultipleOwnershipFiles;Explanation of the SQL query:
- We define a subquery that selects the
FileIDfromFactOwnershipTransfers. - We group the result by to aggregate data specific to each file.
- We define a subquery that selects the