.. (לתיקייה המכילה) | ||
What is considered Java and what is considered SQL commands? | |
Any comparison or check on data you perform out of an SQL command is considered Java. NOTE: The only exception to this is checking the number of results returned from executeUpdate and parsing executeQuery. |
In function getSimilarUsers: | |
In this case you should return an empty ArrayList. |
When deleting song/user/playlist should we delete based on id only or other fields as well? | |
id only. You can assume that the other fields correspond to the object id. |
When doing update song \ playlist \ user what should we find song based on? | |
When updating a tuple you should find it based on the id only and assume that the other fields, beside the one we want to update, are correct. |
Can I see the result of my java code (tests) on the pgadmin server? | |
Yes. The reason you don't see it, is that we clear and drop tables after running test. You can modify AbstractTest class such that it won't call drop and clear tables methods. But then when you will try to run a test again it will say tables already exist. For that, call Solution.dropTables(); before Solution.createTables(); in the createTables method in AbstractTest. |
What should we write in the pdf? | |
The PDF you submit should contain your design: tables, constraints, views, etc.. if you want to add an ERD diagram, go for it, we will appreciate this. you can skip the trivial functions (from your point of view) descriptions but explain the non-trivial ones. this is one of our ways to verify that you understand and know how to use the course material. |
What should we do In function getMostPopularPlaylist in case all playlists are empty? | |
Return the one with highest ID |
When doing updateSongName if both song with song.id does not exist and name is null should we return NOT_EXISTS or | |
You should return NOT_EXISTS. |
When doing addSong on Song which has non zero playCount what should we do? | |
Add it with 0 playing count. |
Can we use the construction which does SELECT during insert? | |
Of course. You will probably need it on addSongToPlaylist... |
In case I have 2 playlists. One with higher ID but with empty songs list (no songs) and one with songs that has playCounts of 0. | |
The one with higher ID (since no songs and songs with playcounts of 0 are equivalent in terms of popularity) |
In deleteUser (and in other delete functions) how should we check if the user we are trying to delete does not exist? | |
The proper way to check it is by checking the value returned from pstmt.executeUpdate(). It returns the number of affected rows in the database. In case it equals 0 you can conclude the user you tried to delete was not in the DB and return NOT_EXISTS. |
In function songPlay if after adding "times" to the song current play count it's got a negative play count number, | |
The value should not be affected by this call. It should remain as before. |
In function getSimilarUsers, If a user follows 0 playlists, who are his similar users? | |
He has no similar users and therefore the function should return an empty ArrayList. |
In getSongsRecommendationByGenre, is a song that doesn't belong to any playlist (but belongs to the | |
Yes. |
When doing setInt to null value I get NullPointerException, what should I do? | |
You can assume that Integer fields won't be null in tests. |
Should we check that a input to a function isn't null? | |
No. You can assume that null value won't be given as input to any function (but there could be null string fields in a given object) |
When trying to add a song to playlist using "INSERT INTO ... SELECT .. FROM ..." I can't check whether the tuple wasn't inserted | |
Right. Look at the update in HW2.pdf in function addSongToPlaylist. |
In the function hottestPlaylistOnTechnify, how do we deal with the case where playlist 1 has rating of 4.5 and playlist 2 has rating of 4? | |
Right. You need to treat them as equal ratings. |
In getMostPopularSong, what should I return if there are no playlists? | |
The string "No songs". |
Does "higher id" mean "bigger id"? | |
If it wasn't clear for some reason "higher"=="bigger" in this context. |
In addSongToPlaylist, how should I check if no tuple was inserted to the DB (in the case I used INSERT INTO .. SELECT ..)? | |
The proper way to check it in this case is: pstmt.execute(); int i= pstmt.getUpdateCount(); if (i==0){ return BAD_PARAMS; } |