.. (לתיקייה המכילה) | ||
Regarding using as few queries as possible... | |
This requirement is only meant for the actual task queries. Each function can be split into two sections: input validation and the actual task. You do not need to minimize the number of queries used for input validation. These queries can and should be separate. The queries you use to actually return the required output (the task queries) should be minimized in the sense that you don't want to make un-necessary queries. This requirement has two goals. First, you should try avoid doing any processing in C and perform as much as possible of the processing in SQL. We've learned from previous semester that attempting to minimize the number of queries also helps in reducing C processing. Second, it helps simulate real world conditions. In a real world scenario the DB server will be remote server which means that each query you perform is another network usage. Obviously, for performance reasons, you would want to minimize network usage during the calculation. As there are many ways to solve each question, there is no one minimal number of queries. The minimum depends on your way of solving the question. If you think you can use less queries, do so. Otherwise, leave it as it is. As long as your solution is reasonable it will be fine. |
May we use temporary tables? lines? values? | |
No. |
Could you provide the commands that were used to create the tables? | |
create table users (id integer primary key, name text not null); create table photos (id integer, user_id integer, primary key (id, user_id)); create table tags (photo_id integer, user_id integer, info text, primary key (user_id, photo_id, info)); |
May we change the tables constraints? | |
No. |
May we install triggers other than the one required in question 11? | |
No. |
The command 'createlang -d dbname plpgsql' doesn't work for us. | |
You should write your username as the dbname. You can also use the next command instead: Create language plpgsql |
May we have an extension due to Hanuka? | |
When publishing the assignment deadline, we have taken into consideration Hanuka and extended the deadline according to it. |
Can you explain again what we should implement in 10, similarPhotos k j. | |
Yes, You should return every photo, X, that comply with the next requirement: There exist at least k different photos such that each of them has at least j tags that the photo X also has. For example: Photo X has the next tags (info field in the tags table): Bridge House Train And photo Y has the next tags: Bridge Sun Train Flower X and Y has 2 tags in common. similarPhotos 1 2 will return X and Y (and maybe other photos). |
When asked to return a photo, why do we have to return also the user id? | |
A photo is represented by 2 fields, user id and photo id. The next 2 photos should not be considered the same: User id 1, photo id 1. User id 2, photo id 1. |
What should we do if an error occurred due to connectivity? | |
You should just print an informative error so we could see it. |
Are we allowed to use C code in order to loop over the result and just print it? | |
Yes, this is the only place you are allowed to perform a loop. The loop should be done in order to print all of the result and not just part of the table. |
In the search command, could you please clarify what should be the number of tags? | |
You should return the number of tags that the photo has with the given word as a substring. If a photo has the next tags: Bridge Sun Train Flower A search that is invoked with the word "i", returns the number 2. |
What should the void* functions return? | |
Whatever you want. If you don't use it, just return NULL. |
Can we assume that every trigger will be removed only once and only after one was installed? | |
Yes. |
A hint for most common tags (command 9). | |
First find the occurrence of every tag. Then use correlated subqueries (תת-שאילתות קשורות הדדית) to determine for each line if it should be in the output. |
In PhotosTags (command 6), may we use join? | |
Yes. |