Skip to content
This repository has been archived by the owner on Jun 18, 2023. It is now read-only.

Commit

Permalink
데이터 베이스 과제 1,2,3
Browse files Browse the repository at this point in the history
Fixes #13
  • Loading branch information
fkdl0048 committed Mar 29, 2023
1 parent 12bd617 commit 404442c
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions HomeWork/1_18011690_이정안_소프트웨어학과_과제123.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# 데이터 베이스 과제

## 1. DDL

### 1.1 DDL문

```sql
create table coursee_anseong
-> (
-> course_name VARCHAR(20),
-> instructor_name VARCHAR(10),
-> start_date DATE,
-> end_date DATE,
-> capacity INT);
```
### 1.2 DDL문에 대한 간략한 설명

* course_name: 강좌 이름이라 최대 20자 정도로 생각
* instructor_name: 사람 이름 최대 10자로 생각
* start_date/end_date: 날짜 형식이라 DATE로 설정
* capacity: 강좌 수용 인원이라 INT로 설정

### 1.3 DDL문 DESCRIBE캡쳐본

![image](https://user-images.githubusercontent.com/84510455/228474981-7572c841-d4a4-428b-a7af-346f7c1f1df5.png)

## 2. DML

### 2.1 DML문

```sql
insert into coursee_anseong (coures_name, instructor_name, start_date, end_date, capacity)
-> values
-> ('생활요리(주간)', '차정미', '2021-09-08', '2021-12-22', 14),
-> ('미용경락', '안유림', '2021-09-06', '2021-12-22', 10),
-> ('한국무용', '진윤정', '2023-01-02', '2023-03-31', 20),
-> ('생활서예', '최훈', '2023-01-02', '2023-03-31', '20'),
-> ('수묵캘리그라피', '김미숙', '2023-02-15', '2023-05-17', 8),
-> ('컨츄리 인형', '박현숙', '2023-05-02', '2023-07-11', 7),
-> ('중급중국어', '오금순', '2023-01-02', '2023-03-31', 30),
-> ('제과기능사', '이은진', '2023-01-02', '2023-03-31', 15),
-> ('라인댄스', '장미', '2023-01-02', '2023-03-31', 20),
-> ('프랑스자수', '장례란', '2023-01-02', '2023-03-31', 15);
```

### 2.2 DML문 SELECT * FROM 테이블이름의 캡쳐본

![image](https://user-images.githubusercontent.com/84510455/228592277-4462003a-5d89-451b-af59-5ab9729fab6e.png)

## 3. DQL

### 3.1 2023년 3월 31일 이후로 끝나는 모든 과정의 수강 인원 합계를 알려주는 서비스

```sql
select sum(capacity) as total_capacity
-> from coursee_anseong
-> where end_date >= '2023-03-31';
```

![image](https://user-images.githubusercontent.com/84510455/228596110-644db7e9-6bd3-46dc-8cf7-01f6f5aaa852.png)

### 3.2 2023년 1월 1일 이후에 시작하는 모든 과정의 이름과 강사 이름, 수강 인원, 수강 기간을 알려주는 서비스

```sql
select coures_name, instructor_name, capacity, end_date, start_date as new_courses
-> from coursee_anseong
-> where start_date >= '2023-01-01';
```

![image](https://user-images.githubusercontent.com/84510455/228597696-f61b5a6c-812c-4124-a99b-fbeaec86dbd9.png)


### 3.3 가장 많은 수강생을 가질 수 있는 수업의 이름을 알려주는 서비스

```sql
SELECT coures_name
-> FROM coursee_anseong
-> WHERE capacity = (
-> SELECT MAX(capacity)
-> FROM coursee_anseong
-> );
```

![image](https://user-images.githubusercontent.com/84510455/228601960-5349270f-08e6-4809-a2a8-1c51c498229e.png)
Binary file not shown.

0 comments on commit 404442c

Please sign in to comment.