05 LINQ-Exercises
05 LINQ-Exercises
This document defines the exercise assignments for the Databases Advanced - Entity Framework course @ SoftUni
You can check your solutions in Judge
MusicHub
People love listening to music, but they see that YouTube is getting older and older. You want to make people happy
and you've decided to make a better version of YouTube – MusicHub. It's time for you to start coding. Good luck
and impress us.
1. MusicHub Database
You must create a database for a MusicHub. It should look like this:
Constraints
Your namespaces should be:
MusicHub – for your StartUp class, if you have one
MusicHub.Data – for your DbContext
MusicHub.Data.Models – for your Models
Song
Id – integer, Primary Key
Name – text with max length 20 (required)
Duration – TimeSpan (required)
CreatedOn – date (required)
Genre – genre enumeration with possible values: "Blues, Rap, PopMusic, Rock, Jazz" (required)
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Follow us: Page 1 of 4
AlbumId – integer, Foreign key
Album – the Song's Album
WriterId – integer, Foreign key (required)
Writer – the Song's Writer
Price – decimal (required)
SongPerformers – a collection of type SongPerformer
Album
Id – integer, Primary Key
Name – text with max length 40 (required)
ReleaseDate – date (required)
Price – calculated property (the sum of all song prices in the album)
ProducerId – integer, foreign key
Producer – the Album's Producer
Songs – a collection of all Songs in the Album
Performer
Id – integer, Primary Key
FirstName – text with max length 20 (required)
LastName – text with max length 20 (required)
Age – integer (required)
NetWorth – decimal (required)
PerformerSongs – a collection of type SongPerformer
Producer
Id – integer, Primary Key
Name – text with max length 30 (required)
Pseudonym – text
PhoneNumber – text
Albums – a collection of type Album
Writer
Id – integer, Primary Key
Name – text with max length 20 (required)
Pseudonym – text
Songs – a collection of type Song
SongPerformer
SongId – integer, Primary Key
Song – the performer's Song (required)
PerformerId – integer, Primary Key
Performer – the Song's Performer (required)
Table relations
One Song can have many Performers
One Permormer can have many Songs
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Follow us: Page 2 of 4
One Writer can have many Songs
One Album can have many Songs
One Producer can have many Albums
NOTE: You will need a constructor, accepting DbContextOptions to test your solution in Judge!
Example
Output (producerId = 9)
Example
Output (duration = 4)
-Song #1
---SongName: Away
---Writer: Norina Renihan
---Performer: Lula Zuan
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Follow us: Page 3 of 4
---AlbumProducer: Georgi Milkov
---Duration: 00:05:35
-Song #2
---SongName: Bentasil
---Writer: Mik Jonathan
---Performer: Zabrina Amor
---AlbumProducer: Dobromir Slavchev
---Duration: 00:04:03
…
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Follow us: Page 4 of 4