Challenges in Enabling Users to Report Twice a Day: Database Table Design and Implementation Issues

36 views Asked by At

We need to create a table that is supposed to represent reports in DDL. It should have the following columns: User (VARCHAR), DATE (DATETIME), Buyer (VARCHAR), ITEM (VARCHAR). The combination (Buyer, ITEM) is a foreign key to another table that represents items for sale. Each user can report no more than twice a day, and a user cannot report the same item from the same seller again. Different sellers can sell the same items.

We are facing difficulty implementing the requirement to allow each user the ability to report twice a day (we cannot use queries only DDL basic tools such as constraints). thank you in advance.

CREATE TABLE REPORTS(
    ITEMNAME VARCHAR(50),
    SELLERID VARCHAR(50),
    UREPORT VARCHAR(50),
    RDATE DATETIME,
    ASSESSMENT INT CHECK(ASSESSMENT=0 OR ASSESSMENT=1),
    PRIMARY KEY (UREPORT, RDATE, SELLERID, ITEMNAME),
    FOREIGN KEY(SELLERID, ITEMNAME)
        REFERENCES CATALOGTOSELL,
    CHECK (SELLERID <> UREPORT),
    UNIQUE (UREPORT, RDATE)
);
0

There are 0 answers