資料庫設計與教學

59
1 資資資資資資資資 2015/10/1 5 John

description

資料庫設計與教學. 2013/10/22. 大綱. 資料表關聯 資料庫正規化 SQL 基本介紹 安裝與建立資料庫、資料表. 資料庫結構. Data Row Data Table. 主索引 (primary key). 必須為資料表內獨一無二的欄位 , 值不可重覆. 系統分析 - 資料表關聯. 設計資料表與資料表之間的關聯 關聯 即為存取資料時可從資料表可得知另一張資料表的相關內容 1. 一對一 2. 一對多 3. 多對多. Example- 學校. 老師 ( 教師代號 , 教師姓名 , 教師電話 ) 學生 ( 學號 , 學生姓名 , 學生電話 ). - PowerPoint PPT Presentation

Transcript of 資料庫設計與教學

  • *2015/10/15

    John

    Enterprise Logisticsand E-Business Center

    SQL

    *

  • *

    Enterprise Logisticsand E-Business Center

    Data RowData Table

    *

    Enterprise Logisticsand E-Business Center

    (primary key), *

    A1234567TinaFemaleNTHUF1234567TomMaleNCTUA1122334JaneFemaleNTU

    Enterprise Logisticsand E-Business Center

    -

    (Cardinality)3 1 2 3

    *

    Enterprise Logisticsand E-Business Center

    Example-(,,)

    (,,)

    *!

    Enterprise Logisticsand E-Business Center

    (,,,)

    (,,)

    *

    Enterprise Logisticsand E-Business Center

    (,,)

    (,,,,)

    *

    Enterprise Logisticsand E-Business Center

    (,,)

    (,,,,) *

  • *

    Enterprise Logisticsand E-Business Center

    (Normalization)

    *

    Enterprise Logisticsand E-Business Center

    *

    0001A01P01150001A01P02120002B01P01150002B01P03150003C01P04100003C01P05200004B02P02120005A02P03150005A02P0410

    Enterprise Logisticsand E-Business Center

    (null)

    *

    0001A01P01150001A01P02120002B01P01150002B01P03150003C01P04100003C01P05200004B02P02120005A02P03150005A02P04100006B02nullnullnull

    Enterprise Logisticsand E-Business Center

    *

    0001A01P01150001A01P02120002B01P01150002B01P03150003C01P04100003C01P05200004B02P02120005A02P03150005A02P0410

    Enterprise Logisticsand E-Business Center

    *

    0001A01P01150001A01P02120002B01P01150002B01P03150003C01P04100003C01P05200004B02P02120005A02P03150005A02P0410

    Enterprise Logisticsand E-Business Center

    (Normalization)

    :

    *

    Enterprise Logisticsand E-Business Center

    :

    *

    11234FirstTomJohn25678SecondMaryJane

    Enterprise Logisticsand E-Business Center

    *

    11234FirstJohn

    11234FirstTom25678SecondMary

    25678SecondJane

    Enterprise Logisticsand E-Business Center

    :key(primary key) key(primary key)table22(primary key)table(primary key)1

    *

    Enterprise Logisticsand E-Business Center

    *(){} {}(){} {}(){} {}key{} a non-key column is dependent on a component of the primary key

    Enterprise Logisticsand E-Business Center

    *{} {}{} {}{} {}

    Enterprise Logisticsand E-Business Center

    :(primary key)

    (primary key)

    (,,)

    (,,)

    *

    Enterprise Logisticsand E-Business Center

    (,,)

    (,)

    (,)

    *

  • *SQL

    Enterprise Logisticsand E-Business Center

    SQLSQL: Structured Query LanguageSQL SQL SELECT SQL(Microsoft Visual Basic / Microsoft Access Jet database engine)

    *

    Enterprise Logisticsand E-Business Center

    SQL

    (DDLData Definition Language) (DMLData Manipulation Language) (DQLData Query Language) (DCLData Control Language)

    *

    Enterprise Logisticsand E-Business Center

    SQL Server with ToolsWindows XPSQL Server 2008 R2 1Microsoft .Net Framework 3.5 SP1 2Windows Installer 4.5 3Windows PowerShell 1.0Express

    *

    Enterprise Logisticsand E-Business Center

    *

    Enterprise Logisticsand E-Business Center

    *

    Enterprise Logisticsand E-Business Center

    *SQL Express

    Enterprise Logisticsand E-Business Center

    *SQLNT_AUTHORITY\SYSTEM

    Enterprise Logisticsand E-Business Center

    *

    Enterprise Logisticsand E-Business Center

    ClientSQL Server 2008 R2SQL Server

    *

    Enterprise Logisticsand E-Business Center

    SQL ServerSQLEXPRESSTCP/IPTCP/IP

    *

    Enterprise Logisticsand E-Business Center

    IPIPAllTCP1433 *

    Enterprise Logisticsand E-Business Center

    SQL ServerSQL Server (SQLEXPRESS)SQL Server *

  • Enterprise Logisticsand E-Business Center

    SQL

    Enterprise Logisticsand E-Business Center

    Enterprise Logisticsand E-Business Center

    SQL

    Enterprise Logisticsand E-Business Center

    * ()Nullnvarchar(MAX)keynvarchar(50)

    Enterprise Logisticsand E-Business Center

    (Numeric Data) SQL integer, float, moneySUM()() (Character & Strings Data) / (Date Data) / date, time, timestamp

    *

    Enterprise Logisticsand E-Business Center

    (Boolean Data) true/false, Yes/No, 1/0 (NULL Data) *

    Enterprise Logisticsand E-Business Center

    *

    Enterprise Logisticsand E-Business Center

    *

    Enterprise Logisticsand E-Business Center

    *

    Enterprise Logisticsand E-Business Center

    *

    Enterprise Logisticsand E-Business Center

    *

    Enterprise Logisticsand E-Business Center

    *

    Enterprise Logisticsand E-Business Center

    *

    Enterprise Logisticsand E-Business Center

    *

    Enterprise Logisticsand E-Business Center

    *

    Enterprise Logisticsand E-Business Center

    *

    Enterprise Logisticsand E-Business Center

    *

    Enterprise Logisticsand E-Business Center

    *

    Enterprise Logisticsand E-Business Center

    *

    Enterprise Logisticsand E-Business Center

    ER Model *

  • Q&A Time

    **Data Table

    Data RowDataTable***

    ***

    *** [] *tablekey=?? key=key=table2keykey=()

    () ()

    () keykey*non-key column is dependent on a component of the primary keykeykey*(Transitivity) AB BC AC

    (Partial Functional Dependence): XY H X ( H X ) HY Y X Y X**True False1 01 True0 False*