{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'Connected: @None'" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%load_ext sql\n", "%sql sqlite://" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "활동 6b\n", "------------\n", "\n", "MVDs. 먼저 아래의 테이블을 추가해보자:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Done.\n", "Done.\n", "1 rows affected.\n", "1 rows affected.\n", "1 rows affected.\n", "1 rows affected.\n", "1 rows affected.\n", "1 rows affected.\n" ] }, { "data": { "text/plain": [ "[]" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%%sql\n", "DROP TABLE IF EXISTS courses;\n", "CREATE TABLE courses (course TEXT, staff TEXT, student TEXT);\n", "INSERT INTO courses VALUES ('CS949','Amy','Bob');\n", "INSERT INTO courses VALUES ('CS145','Chris','Deb');\n", "INSERT INTO courses VALUES ('CS145','Chris','Eli');\n", "INSERT INTO courses VALUES ('CS145','Firas','Deb');\n", "INSERT INTO courses VALUES ('CS145','Firas','Bob');\n", "INSERT INTO courses VALUES ('CS145','Firas','Eli');" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 문제 1\n", "\n", "지난 시간까지는 python 도구를 사용하여 문제들을 풀었다. 이제 다시 SQL로 다시 돌아오자. 교사와 M과목간의 관계가 **MVD일 때만** 출력하는 SQL 질의문을 작성해보자. \n", "\n", "그리고, 위에 테이블을 생성하고 값을 저장한 SQL문에서 테이블이 MVD를 만족하도록 불필요한 INSERT 명령 줄을 주석처리하자." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%%SQL\n", "SELECT \n", "FROM \n", "WHERE ;" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.5" } }, "nbformat": 4, "nbformat_minor": 2 }