Presentation is loading. Please wait.

Presentation is loading. Please wait.

HSCI 709 MySQL Lecture 13.

Similar presentations


Presentation on theme: "HSCI 709 MySQL Lecture 13."— Presentation transcript:

1 HSCI 709 MySQL Lecture 13

2 Review of SQL Commands

3 Starting mysql

4 Listing Existing Databases

5 Creating a New Database

6 Connecting to a Database

7 Create Table Statement

8 Deleting a Table

9 A Simple Information Model
PHYSICAL TABLES PAT PAT_CLNCIAN_ASSOC PAT_ID INT PAT_ID INT CLNCIAN_ID INT PAT_FNM VARCHAR(20) PAT_LNM VARCHAR(35) PAT_CLNCIAN_IDX INT ASSOC_BEGIN_DT DATE ASSOC_END_DT DATE ASSOC_CAT_CD TINYINT CLNCIAN CLNCIAN_ID INT CLNCIAN_NM VARCHAR(250)

10 SQL Commands CREATE TABLE PAT ( PAT_ID INT NOT NULL PRIMARY KEY,
PAT_FM VARCHAR(20), PAT_LNM VARCHAR(35) ) TYPE=INNODB; CREATE TABLE CLNCIAN( CLNCIAN_ID INT NOT NULL PRIMARY KEY, CLNCIAN_NM VARCHAR(250) CREATE TABLE PAT_CLNCIAN_ASSOC( CLNCIAN_ID INT NOT NULL, PAT_ID INT NOT NULL, PAT_CLNCIAN_IDX INT NOT NULL, ASSOC_BEGIN_DT DATE, ASSOC_END_DT DATE, ASSOC_CAT_CD TINYINT NOT NULL, INDEX(CLNCIAN_ID), INDEX(PAT_ID), PRIMARY KEY(CLNCIAN_ID, PAT_ID, PAT_CLNCIAN_IDX), FOREIGN KEY (CLNCIAN_ID) REFERENCES CLNCIAN(CLNCIAN_ID), FOREIGN KEY (PAT_ID) REFERENCES PAT(PAT_ID)

11 Verifying the Tables

12 Loading Data into PAT Table
INSERT INTO PAT(PAT_ID,PAT_FNM,PAT_LNM) VALUES (45671,'JOHN','DOE'), (45672,'JENNY','DOE'), (45673,'CINDY','FINNEGAN'); INSERT INTO PAT(PAT_LNM,PAT_FNM,PAT_ID) VALUES ('MARTINEZ','MANUEL',45674), ('VALLARES','MARGARITA',45675);

13 Loading Data into CLNCIAN Table
INSERT INTO CLNCIAN(CLNCIAN_ID,CLNCIAN_NM) VALUES (8998,'DR. FERNANDO DE LA ROSA'), (8999,'DR. DIETLINDE WEINSTEIN'), (9000,'DR. PIERO LUIGI DELLA MIRANDOLA');

14 Loading Data into PAT_CLNCIAN_ASSOC Table
INSERT INTO PAT_CLNCIAN_ASSOC(CLNCIAN_ID, PAT_ID, PAT_CLNCIAN_IDX, ASSOC_BEGIN_DT, ASSOC_END_DT, ASSOC_CAT_CD) VALUES (9000,45671,1,' ',' ',3), (9000,45671,2,' ',' ',1), (8998,45671,1,' ',' ',3), (8999,45672,1,' ',' ',2), (8998,45674,1,' ',' ',2), (8999,45673,1,' ',' ',1), (8998,45675,1,' ','',3);

15 Referential Integrity
There is no record in the CLNCIAN table with CLNCIAN_ID = 9005

16 SELECT Statement

17 SELECT {fields} Statement

18 SELECT DISTINCT Statement

19 SELECT COUNT Statement

20 JOINS SELECT PAT_FNM, PAT_LNM, CLNCIAN_NM,ASSOC_BEGIN_DT
FROM PAT, CLNCIAN, PAT_CLNCIAN_ASSOC WHERE PAT.PAT_ID = PAT_CLNCIAN_ASSOC.PAT_ID AND CLNCIAN.CLNCIAN_ID = PAT_CLNCIAN_ASSOC.CLNCIAN_ID AND PAT.PAT_LNM = 'DOE';

21 CASE TOOLS

22 Creating Tables in DBDesigner 4

23 Creating Links

24 Exporting the SQL Script

25 The SQL script file(1)

26 The SQL script file(2)

27 Running the SQL Script

28 Checking the Results

29 Summary Business Domain Abstraction we are here Modeling SQL DB
Case Tools Physical Model Implemented Physical Schema Logical Information Model


Download ppt "HSCI 709 MySQL Lecture 13."

Similar presentations


Ads by Google