Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Companion 관련 Table 수정했습니다. #8

Open
jeongseonwoong opened this issue Aug 1, 2024 · 0 comments
Open

Companion 관련 Table 수정했습니다. #8

jeongseonwoong opened this issue Aug 1, 2024 · 0 comments
Assignees

Comments

@jeongseonwoong
Copy link
Collaborator

jeongseonwoong commented Aug 1, 2024

수정사항이 많아서 기존에 Appointment User 테이블 새로 만들어 주실수 있을까요?

1.User 테이블 생성
CREATE TABLE USER(
id INT NOT NULL PRIMARY key,
pw varchar(20) NOT NULL,
userName VARCHAR(20) NOT NULL,
userType VARCHAR(20) CHECK(userType IN('WHEELCHAIR','COMPANION')),
location VARCHAR(20),
rate DOUBLE,
times INT DEFAULT 0
);

  1. Appointment 테이블 생성
    CREATE TABLE Appointment(
    id INT NOT NULL primary key,
    wheelchairId int,
    companionId INT,
    appointDate DATE NOT NULL,
    location varchar(20) NOT NULL,
    bill INT NOT NULL,
    FOREIGN KEY (wheelchairId) REFERENCES USER (id)
    ON DELETE set null
    ON UPDATE CASCADE,
    FOREIGN KEY (companionId) REFERENCES USER (id)
    ON DELETE set null
    ON UPDATE CASCADE
    );

3.UserAppointment 테이블 생성 후 foreign key로 다대다 관계설정
CREATE TABLE UserAppointment(
userId INT ,
appointmentId INT,
FOREIGN KEY (userId) REFERENCES USER (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY (appointmentId) REFERENCES Appointment (id)
ON DELETE CASCADE
ON UPDATE CASCADE
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants