I have this app where I have the genre of music that the user is liking and whenever a user listens to a song he rates it.I want to show them the most relevant songs that the users might like.How do I carry on the database schema?What all data should I take from a user and how to get the most relevant song for the particular user?
Clear Explanation is appreciated.
This is a very active field of research known as recommender systems. If you wish to deal with it seriously, database design is only a first step; you will need to think about a suitable algorithm etc. Your question was specifically about the database schema, so I recommend the following readings:
RecDB in Action: Recommendation Made Easy in
Relational Databases
Recommender system datastructures
Are you recommending the user songs based on his ratings only? In that case, you might need every user in your database to rate at least a few songs. If a user has not yet rated any songs (maybe he signed up for your application recently), you will not be able to recommend him any song. This problem, is called "The Cold Start Problem".
Coming to the question, you can group songs by either genre, artist, album, year or you can take any combination of these parameters. So, your Songs table will have these values along with name of the song, and probably a unique ID. Users table can be as small as UserID and name or you can include his age, location so that you can recommend him songs based on other user's likings with similar age and location.
There would also be a User-Song map table that contains the ratings that every user gives different songs (one-to-many mapping). This table can be used to find a user's favourite song(s)
Related
One of the latest projects is to organise an outdoor summer music festival known as the ‘Long-Weekend’ over a three-day period, and they really need a system to help them record and access the data. It is hoped that the festival will attract between 4000 and 5000 fans each day during the three-day period. Recently they had an event of folk music festival in Roundhay Park, Leeds. They haven’t got much social media presence, therefore, they would like to include links to relevant social media as part of your final product. The system needs to be accessible to multiple users.
In addition to above, here is a list of some other important information we need to include in the system:
Details for each Festival and the key organizer of the Festival.
Details of Venues and Locations where the festival is taking place, and Contact person for the Venue
Details of Venue as they may be of a different types/sizes and hire price.
List of all staff working at the Festival
List of Bands playing at Festival.
Additional Entertainment to keep fans occupied over a period
The music bands represented by an agent need to play a prominent Venue
Space for band/singers should be allocated for storage
A list of bands on each location, times and dates are kept
Allocation of staff to a stage and supervisor and the ability to record feedback
Reporting on the equipment list for each stage
Security staff allocated to a venue and each stage (if applicable)
Information of qualified first aiders.
Well this forum is purely related to code stuff while you have asked some conceptual to logical conversion.
Anyway, I will try to answer:
Identify the entities like bands, venues, staff etc
Identify their attributes like bandId, bandTitle or venueTitle, venueAddress, venueContactPerson
Identify the strong/week/multiple/composite attributes of these entities for example title of band will be single, address can be composite by combination of streetAddress, streetNo, sector, city etc, contactPerson can be multiple
Identify the relations between entities for example band has many staff member, a member can not be part of multiple bands etc
Try to Draw diagram by following https://www.smartdraw.com/entity-relationship-diagram/
Further, you can email me at ping#naveedramzan.com
So I have a war-like game with three tables: User, Player, and Game.
The User table contains email, username, password hash, and other user-specific info.
The Game table contains info about each game and the state of each game world.
The Player table contains info about each player in a game: how many units they have, etc.
I have the following relationships:
A one-to-many relationship between User and Player, since each User can be in several different Games, and control several different Players simultaneously.
A one-to-many relationship between Game and Player, since each Game has multiple Players in it.
So in order to find the Games that a specific User is in, is it better practice to either:
Make a many-to-many relationship between User and Game, or
Write a function that takes the list of Players from a User, then find the Game IDs from the Player columns?
(I'm using SQLAlchemy with SQLite and Flask, but I don't think that's important to this question.)
The attached image may explain it better: should I have any database connections between User and Game?
I'd be glad to clarify anything, and thanks for any possible help! Sorry if this is a bad question for StackOverflow.
When a many-to-many relationship exists, say gameUsers, a common implementation is to create an intermediary table, containing the ids of each of the tables, in this case a list of user_id, game_id pairs representing which games each user is in.
But... you already have such a table, the player table. So my approach would be to think of the player table as that resolution table. The player table already contains which games each user is in, so that second many-to-many is not really required.
I have a goal to implement database schema for simple \ typical social network.
I have read many threads \ answers but have couple open questions.
So we have User table (userId, name and etc). We can make some Actions (reply, like, follow and etc). I want to implement some log for all activities and do it as PULL-MODEL. So we write entry in Activity table for any action. Schema for this table is (id, ownerId, actionType, targetId, time) where ownerId is User's id, who made action. actionType is reply, follow or other action. targetId is id of user or post and depends on actionType. When User get his activities we just do query by friends ids. So it is clear for me. My questions are:
1) In case if I follow User and unfollow him, what I should do? Should I make two entries in Activity table or I should remove the first followAction entry? What is the best practice?
2) It is clear foe me do query by friend ids so I get all activities of my friends. But in case any not my friend liked my photo and I must get event that "Some not my friends liked my photo". So, what are good solutions there for this case. May be I must to change my current schema?
Releated questions :
How to implement the activity stream in a social network
Database Design - "Push" Model, or Fan-out-on-write
What's the best manner of implementing a social activity stream?
Thanks you all for good answers.
First, it may be better to split each kind of action into its own table, rather than having all actions in one table, distinguished by types. This makes your metadata about each action more flexible; as you say, the target ID depends on the action; without splitting them out into other tables, it's harder to write constraints on what the data should be.
Second - on your question #1, I think you're confusing a log of user actions with user status. You may need both; you might want two separate data structures. For example, if a user follows and then unfollows, the status is that they aren't following, but the log of actions is that they followed, then unfollowed. So I think you should be careful to have a separate data structure that captures current status of certain relationships, apart from actions. Then the problem becomes simpler, you log all actions as they happen, and update status accordingly.
For question #2, the photo should be its own data object, with "likes" split out into a different table; users like posts. Then of all of the users who like a post, they can easily be grouped into two categories; friends (those who have a friend relationship to the poster) and non-friends.
Looking through the Soundcloud documentation - it doesn't appear that you can pull the artist name and the song name separately (or am I missing something?):
http://developers.soundcloud.com/docs/api/reference#playlists
ie:
for song https://soundcloud.com/yaz-francis-1/pompeii-bastille
Artist: Bastille
Song: Pompeii
Is it just combined in the tracktitle (title)? User is also not always the song artist name, but the username of the person who posted it to soundcloud.
If not, is there anyway to pull Artist Name and Song separately?
Any help would be greatly appreciated - thanks!
Best,
JP
Well the API doesn't give you the fields separately, but depending on your application there might be a way to get that data anyway.
I have written a webapp using the Soundcloud API and I am actually extracting the artist name separately. If you're interested, I can tell you howI did it.
You need to apply some NLP-tricks and use regular expressions.
I'm in the process of building a Web app for a client who owns a record label and wants to publish 5000+ songs of varying artists and albums. I have diaected the api to death and found the best way to tie a track to an artist is by using tags. This way you can also search by the artist name and get results in the api. In my particular case I am using machine tags to store the artist, album and track name. I also store another tag as a key for finding only tracks that match that key so on my Web app I don't get tracks from other users, since you can't filter results by tags and genre when getting tracks from a specific user.
It's a but messy but it works. So something like this to get all songs by this artist on my Web app from a specific users account
/tracks.json?client_id=xxx&q=app:key=uniqueid&tags=app:artist=artist+name
You can also throw genre in there too if you wanted. Hope this was helpful
So I'm working on an application that has a feature that generates a list of 100 or so artists that are similar to those in the user's music catalog using the Echo Nest API. Then, a user can supply a certain year, and, based on the similar artists, the application will return a list of albums that were released on that year.
The only problem is that I have no idea how to filter albums based on year. The Echo Nest API doesn't really do much with albums. The Discogs and Last.fm APIs work with albums, and the Discogs API has data about albums' release dates, but there is no way to filter an initial query by release date. For example, if I have the artist Fleet Foxes and I want to filter it by albums released in 2011, there is no option to search for albums by the Fleet Foxes confined to release dates of 2011.
The only option I can really see at this point is iterating over EVERY album an artist has and only adding those albums that meet my specifications. However, this is obviously very heavy on both the APIs and my server, especially considering that many of the artists in the list of 100 similar artists will have no albums that match my criteria and that many artists have well within the range of 100 albums when you take into consideration singles, remixes, etc.
Does anyone see a better way of doing this?
If an API really doesn't have any way to filter by year, then yes, of course you will have to pull down all of the releases and filter them after the fact.
If you think this is a burden on your code and/or their server, you should file a feature request to add the filtering.
However, you should make sure first that they really don't provide such a thing. Most REST APIs separate "fetch" and "search". For example, http://api.example.com/artists/12345/releases may not have any way to filter it, but http://api.example.com/search?type=releases&artist=12345&year=2011 may exist.
Without looking into all of the APIs in detail, a quick check of Discogs' "Run a search query" docs shows that you can include a year criterion in the search (although it looks like maybe you can't actually search by artist ID, just by artist name?).