Giter Site home page Giter Site logo

hezean / sustc Goto Github PK

View Code? Open in Web Editor NEW
22.0 7.0 9.0 244 KB

Template for project 2 of SUSTech Principles of Database Systems (CS307 / CS213), 23 fall semester.

Home Page: http://172.18.34.154

License: MIT License

Java 100.00%
cs213 cs307 database sustech

sustc's Introduction

it's chris, a mcomp student at nus 🦁

Gmail Twitter URL

sustc's People

Contributors

hezean avatar matthew-leng avatar sses7757 avatar whatweat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sustc's Issues

[BenchmarkService] some fields in videoRecords is zero

Related module

Benchmark

What happened

When testing my code, I found out that certain fields that were supposed to have values turned out to be null.Thus, I add a log in the benchmarkService, and someaFields in video records is null, I wonder if I made some mistake or there's actually a bug. Thanks
Snipaste_2023-12-08_01-24-47

What you expected to happen

No response

How to reproduce

No response

Anything else

No response

A question about the implementation of deleteAccount

/**
* Deletes a user.
 *
 * @param auth indicates the current user
 * @param mid  the user to be deleted
 * @return operation success or not
 * @apiNote You may consider the following corner cases:
 * <ul>
 *   <li>{@code mid} is invalid (<= 0)</li>
 *   <li>the {@code auth} is invalid
 *	 <ul>
 *	   <li>both {@code qq} and {@code wechat} are non-empty while they do not correspond to same user</li>
 *	   <li>{@code mid} is invalid while {@code qq} and {@code wechat} are both invalid (empty or not found)</li>
 *	 </ul>
 *   </li>
 *   <li>the current user is a regular user while the {@code mid} is not his/hers</li>
 *   <li>the current user is a super user while the {@code mid} is not his/hers</li>
 * </ul>
 * If any of the corner case happened, {@code false} shall be returned.
 */
boolean deleteAccount(AuthInfo auth, long mid);

Does this method require us to do user deletion where auth is the operator and mid is the id of the account being deleted. If so, then the last corner case may be changed as "the current user is a super user while the mid IS his/hers" (i.e. a regular user can delete himself/herself but a super user can't).

[UserService] Confusion about AuthInfo

Describe your question

I have confusion about the validation of AuthInfo.

     *   <li>the {@code auth} is invalid
     *     <ul>
     *       <li>both {@code qq} and {@code wechat} are non-empty while they do not correspond to same user</li>
     *       <li>{@code mid} is invalid while {@code qq} and {@code wechat} are both invalid (empty or not found)</li>
     *     </ul>
     *   </li>

In my understanding, there are four ways of validation:

  • Validate by mid and password
  • Validate by qq
  • Validate by wechat
  • Validate by qq and wechat

My questions are:

  • Will mid be provided in the latter 3 validations?
  • Could there be a composite validation with password and qq/wechat? (For example: An AuthInfo with mid, password and qq provided)

i wonder how to calculate the coins in class [UserInfoResp]

Describe your question

notice that in the class [UserInfoResp], the number of coins a user owns is needed. but we didn't know the number of coins a user owns when it is registered or imported. If we just simply give it a number of 0, then nobody can give coin to a video. It's strange.
So, please give a particular method for us to calculate the coins.

btw, there are other fields such as level whose calculate method is not declared clearly. it is hard for us to decide how to implement the interfaces.

[Danmu Service] What does the argument "long id" in method likeDanmu() refers to?

Describe your question

/**
     * Likes a danmu.
     * If the user already liked the danmu, this operation will cancel the like status.
     * It is mandatory that the user shall watch the video first before he/she can like a danmu of it.
     *
     * @param auth the current user's authentication information
     * @param id   the danmu's id
     * @return the like state of the user to this danmu after this operation
     * @apiNote You may consider the following corner cases:
     * <ul>
     *   <li>{@code auth} is invalid, as stated in {@link io.sustc.service.UserService#deleteAccount(AuthInfo, long)}</li>
     *   <li>{@code id} is invalid (<= 0 or not found)</li>
     * </ul>
     * If any of the corner case happened, {@code false} shall be returned.
     */
    boolean likeDanmu(AuthInfo auth, long id);

What does "the danmu's id" means? Beaucase there is no attribute refers to "id" in the DTO class DanmuRecord. Does it means we should assign an id to each danmuRecord?
Similarly, when users are registering, should we assign an mid to each of them? When videos is being posted, should we assign a bv to each of them?

[Benchmark] Invalid birthday in big data

Related module

Benchmark

What happened

The format of birthday is not "X月X日"

ERROR 7760 --- [ main] i.s.service.impl.DatabaseServiceImpl : Invalid birthday: 02-29

What you expected to happen

No response

How to reproduce

Change the data or give a clear decription of birthday.

Anything else

No response

[BenchmarkService] Will the full test code be released?

Describe your question

I noticed that only the importData functionality is tested in the benchmark currently, and I was wondering if the full test code will be released to we students to verify the correctness of the program? Thanks.

Question about Initializing Database

Describe your question

When we submit the files, do we have to contain all the create table commands in the .sql file, or can we just provide an empty .sql file and create tables in the Java program?

[bootRun] passing negative integers to command options

Related module

Shell

What happened

When I use the 'rec general' command and enter invalid pagenum and pagesize(like -1 -1), it will automatically take the default value(1 10), then how to test my API implementation of corner case. If my input is valid, it will take it as the correct input.

What you expected to happen

No response

How to reproduce

No response

Anything else

No response

[Benchmark] Resource Limitation

Describe your question

I need to know the resource limitations for my program and the database during benchmarking, including but not limited to the program's runtime memory, database disk storage space, database user permissions, and related database configurations. This information will assist me in debugging the program and setting parameters.

Some questions about [deleteAccount] and [deleteVideo].

Describe your question

If an user was deleted, should the things related to this user be deleted?
(These things may include: posted videos, reviewed videos, given likes, given coins, view history, collect information, sent danmu, followed by others, etc.)
If a video was deleted, should the things related to this video be deleted?
(These things may include: likes, collects, coins, view history, danmus, etc.)

[Testing error] dataSource() is null when testing

Describe your question

#32 (comment)
Hello review, I was trying to test the implementation as told in the upper issue. The error is this.dataSource() is null, more detailed error in the image below.

image

I have already added@Autowiredmark before the dataSource. Since I use helper class to execute certain sql commands, datasource is instantiated in the helper class. I have also added @Component annotation before the class (otherwise @Autowired does not work).

image

How to solve this problem? Thank you.

What should we submit

Describe your question

请问我们是需要交以下文件吗?

1. 报告(pdf格式)

报告名为 sid1_sid2_sid3_Report.pdf

2. submit文件夹的压缩包

submit文件夹结构如下

submit 
├── tables.sql      (建表语句)
└── sustc-api.jar  (由submitJar生成)

其中.sql文件中,需要包含全部建表的sql语句,不需要创建数据库的sql语句,但是需不需要创建user并赋予权限的语句?
比如以下这一类

create user manager with password '123456';
grant connect on database project2 to manager;
grant usage on schema public to manager;
grant select, insert, update, delete, truncate on all tables in schema public to manager;

submit文件夹应该用sustc的submitJar命令生成,还是应该用sustc-api的submitJar命令生成submit文件夹?

3. sustc-api的src文件夹的压缩包

是否要把dto和接口删除,只保留实现类呢?还是全部保留?

[Benchmark] Invalid Data

Describe your question

When running on the benchmark data from DB Project Benchmark, the data(zip SHA256: 8445ee4a1fa5786766b91dfde31a9c1e3f3ef68a8b4e6e8c62e9e0699c93a5d7) seems to violate some constraints about user.

  • User name should be unique
  • User birthday should not be null or empty
ScreenShot

After I removed the constraints, the data in my table is as shown above.
It seems that some user names cannot be recognized by DataGrip, and birthday is empty for some users.

Visibility issue in getUserInfo

Describe your question

In method getUserInfo, which kind of result shall we return (take videos that a user has watched for example):

  • All videos that the user has watched (including deleted videos, videos not reviewed yet and videos not published yet).
  • All videos in the database that the user has watched (including videos not reviewed yet and videos not published yet).
  • All videos that the user has watched and can be searched by regular users.

Since the authentication information is not provided, we can't return different results base on different identities.

[PostVideoReq] Different data types of attribute "duration"

Related module

Code in sustc-api

What happened

Attribute duration has different data type in PostVideoReq (long) and VideoRecord (float).

What you expected to happen

Data type of duration in PostVideoReq should be changed as float.

How to reproduce

No response

Anything else

No response

[Judgement] Check the correctness

Describe your question

The BenchmarkService in the branch can't check the correctness of the application. We can't submit it to the website, too. So how can we check our application. Could you update a new BenchmarkService which can check the correctness?

[AuthInfo] What result are the following 16 cases?

Describe your question

There are 4 fields in AuthInfo, which are mid, password(pw for short), qq, wechat(wx for short). So there are 16 combinations of this 4 fields. Now I want to know for each combination, how can the user login in successfully. (In the following cases, 1 means have this field, 0 means this field is null or empty)

0mid, 0pw, 0qq, 0wx:

all don't have, can't login

0mid, 0pw, 0qq, 1wx:

if can find wx(the wx belongs to user A)
    login
else cannot find wx
    cannot login

0mid, 0pw, 1qq, 0wx:

if can find qq(the qq belongs to user A)
    login
else cannot find qq
    cannot login

0mid, 0pw, 1qq, 1wx:

if at least one of qq, wx cannot find
    cannot login
else 
    if wx and qq belongs to the same people, login; else, cannot login

0mid, 1pw, 0qq, 0wx:

only have password, cannot login

0mid, 1pw, 0qq, 1wx:

if wx cannot find
    cannot login
else wx can find (this wx belongs to user A)
    pw of user A is correct, login; else, cannot login

0mid, 1pw, 1qq, 0wx:

if qq cannot find
    cannot login
else qq can find (this qq belongs to user A)
    pw of user A is correct, login; else, cannot login

0mid, 1pw, 1qq, 1wx:

if at least one of qq, wx cannot find
    cannot login
else (qq and wx both can find)
    if qq and wx not belongs to the same user
        cannot login
    else (both belongs to user A)
        pw of user A is correct, login; else, cannot login

1mid, 0pw, 0qq, 0wx:

only have mid, cannot login

the other 7 cases

1mid, 0pw, 0qq, 1wx:
1mid, 0pw, 1qq, 0wx:
1mid, 0pw, 1qq, 1wx:
1mid, 1pw, 0qq, 0wx:
1mid, 1pw, 0qq, 1wx:
1mid, 1pw, 1qq, 0wx:
1mid, 1pw, 1qq, 1wx:

    if mid cannot find
        cannot login
    else (mid can find)
        all the other provided info should match this user's authentic info, otherwise cannot login

Thanks a lot!

[dbimport] operating benchmark throw errors

Related module

Benchmark

What happened

QQ图片20231216162132
Detailed information is in the following document.
text.txt

What you expected to happen

No response

How to reproduce

No response

Anything else

It works fine on the computers of other members of the team.

Some questions about the runner's data and the field mid

Describe your question

  1. I would like to use foreign keys to link my tables, but the data provided in the runner obviously violated the constraints, e.g., a user would follow another user whose mid is not in the userrecord. Is there some new data available now?
  2. The method register requires us to return a new users mid, but where is the mid from, do we need to find a way to generate the mid ourselves? And what is the length of the mid? It seems that the longest uid in Bilibili has 10bits (maybe I'm wrong
    Expecting for your answer~

[Invalid import data] Too long sign

Related module

Benchmark

What happened

In the small-data, it exists a invalid data.

WARN 11572 --- [ main] i.s.service.impl.DatabaseServiceImpl : User mid: 1574680
ERROR 11572 --- [ main] i.s.service.impl.DatabaseServiceImpl : Sign is too long: ♡。 ...   一个人,走两个人的路。

What you expected to happen

In Bilibili, the limitation of personal sign is 70 characters, as of my posting time. But in this data, the length is 92.

How to reproduce

If you consider it as a normal data, I think you should provide us A DETAILED DOCUMENT ABOUT EACH DATA.

Anything else

I have mentioned it before.

Thanks.

a question about coin

Describe your question

when a user gives a coin to a video, will his coin number change? What is the case when importing?

[UserService] The data for test is invalid against the request of register

Describe your question

In register, we need a valid birthday (not null nor empty). But the data in users.csv doesn't have the birthday.
And another question about the UserRecord is that the type of gender should be same as RegisterUserReq.

It's important to tell us the detail of input data constraints. Such as "男" or "Male", and the data format of the birthday.

bootrun error

Related module

Code in sustc-api

What happened

I have implemented the UserService method, while in the testbench i can't test it coz i can't see the command:
image
image

What you expected to happen

No response

How to reproduce

No response

Anything else

No response

About RecommenderService impl recommendVideosForUser method

Describe your question

请问一下RecommenderService这个接口第三个方法recommendVideosForUser描述中提到If the current user's interest is empty, return {@link io.sustc.service.RecommenderService#generalRecommendations(int, int)}.
* If the requested page is empty, return an empty list
还提到{@code pageSize} and/or {@code pageNum} is invalid (any of them <= 0)
请问这个requested page为空包含什么呢?感觉如果page等于0就被第三种情况包含了,查询结果为空被第一种情况包含了

这个接口中方法要求提供的pageSize和pageNum具体是什么意思?是要求提供多少页还是要求提供第几页?

Questions about table creation

Describe your question

Hello reviewer. It seems that the submitted file does not contain table creation files (or does it?), then how are you going to judge the result? Thank you.

SearchVideo details

Describe your question

In the searchVideo method, should we show the video whose relevance is 0 (cannot match any keywords)?

About the table design

Describe your question

Must we design the table according to the test cased? For example, can we separate into smaller tables for design purpose?

file not found when import

Related module

Code in sustc-api

What happened

Uploading danmu.jpg…

What you expected to happen

No response

How to reproduce

No response

Anything else

No response

missing option

Describe your question

image do not kown why missing option

Question about searching the video

i wonder if a user can search a video which is published and reviewed and updated but not re-reviewed.
a natural idea is that the previous version can be searched while the updated version cannot, but this would lead to a great amount of work(Maybe)

[VideoService] A question about review and re-review

Describe your question

Hello review. My question is about review in VideoService. The two descriptions below seem to be confusing.

From method updateVideoInfo

    /**
     * Updates the video's information.
     * Only the owner of the video can update the video's information.
     * If the video was reviewed before, a new review for the updated video is required.
     * .................................................
     * @return {@code true} if the video needs to be re-reviewed (was reviewed before), {@code false} otherwise

From method reviewVideo

/**
     * Reviews a video by a superuser.
     * If the video is already reviewed, do not modify the review info.
     * You may consider the following corner cases:
     *   .............................................
     *   the video is already reviewed
     * If any of the corner case happened, false shall be returned.

According to this account, if updateVideoInfo returns true, then we shall re-review the video. However, since it is already been reviewed (otherwise updateVideoInfo would have returned false), it doesn't need to be reviewed again. And there is no re-reviewVideo method.

Can you clarify this? Many thanks!

[DatabaseServiceImpl] About database source

Describe your question

Should we open and close our database source in every method we implemented? Or the test will open database source at the beginning and closed at last. In class DatabaseServiceImpl method sum(int a, int b), the source is opened and doesn't close, is it a bug or the testbench will automatically close all source at last.

Should we write the log in APIs?

Describe your question

In DatabaseServiceImpl.sum(), you write the log as log.info("SQL: {}", stmt);. However, in DatabaseServiceImpl.truncate(), you don't write the log. I'm wondering that should we write the log in every api we implemented? Does it count in the final grading? Is there any rules about that(when to use info, debug, error, how to record time, etc.)?

[VideoService] What is the return of getHotPot()?

Describe your question

The definition of 'Hotpot' in the comments refers to the interval with the 'most' Danmu, but the return value is a set containing the index or indices of hotpot's'. Could you clarify whether it is one or multiple?

Visibility in RecommenderService

Describe your question

In the recommendVideosForUser method, should the recommended video filter out the video that is not visible to the user?

[io.sustc.service.RecommenderService#generalRecommendations(int, int)] Counting of the rates of like/coin/favorite

Describe your question

In the RecommenderSerivice, we are asked to implement a method generalRecommendations(int, int). The implNote stated that Though users can like/coin/favorite a video without watching it, the rates of these values should be clamped to 1. What does it mean by clamping the rates of the values to 1?

  • Does that mean if there are users who like/coin/favorite a video without watching it, then the like/coin/favorite rates for the video should be set to 1?
  • Or does that mean we need to count all the like/coin/favorite without caring whether the users watch the video? Will the benchmark given produce results larger than 100%?

Thank you for your prompt responding!

disappeared command

Related module

Shell

What happened

Throws an exception after entering a command:No command found

What you expected to happen

No response

How to reproduce

No response

Anything else

No response

file not found when import

Related module

Code in sustc-api

What happened

danmu

What you expected to happen

No response

How to reproduce

No response

Anything else

No response

Some questions about the project.

Describe your question

Q1. How a user earn coins?
Because [UserInfoResp] is the only class which has the number of coin and we can not get this information from [users.csv]. But in the document of [VideoService.coinVideo()], coin number greater than zero is required.
Q2. Difference between push and public?
In the [project description.pdf 1.1 Entities of SUSTC Video], it said a video is visible only after the owner public the video. But in [VideoService], we only have [postVideo]. Should we clarify the difference? Or we can consider that a video is visible for everyone after the review?
Q3.
In the document of [VideoService.searchVideo()], there is a corner case: "the video is not visible to current user" and it said "If any of the corner case happened, null shall be returned." But the case that a video is not visible is common (for example, the video is waiting for reviewing). Should we always return null just because there is an invisible video appear in the result?
Q4.
In the document of [RecommenderService.recommendVideosForUser], what is the meaning of "both user's followers and his/her followees have watched"? Is whether "both (one of user's followers) and his/her (one of followees) have watched" or "both (all of user's followers) and his/her (all of followees) have watched"?
Q5.
Also in the document of [RecommenderService.recommendVideosForUser], what is the meaning of "friends"? Is "A is B's friend iff A is B's both follower and followee" the correct understand?

Thank you for answering my questions and correnting my misunderstands.

[VideoService] A question about viewTime

Describe your question

Hello reviewer. My question is, if a user watches a video multiple times, what shoulded be recorded in viewTime? Multiple records with view time for each watching, or the viewTime of user's latest watching?

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.