Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

20
Database Design and Creation Using MyS QL Track 3 : Basic Course in Database

Transcript of Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

Page 1: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

Database Design and Creation Using MySQL

Track 3 : Basic Course in Database

Page 2: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

Learning Objectives:

At the end of the session, you should be able to:

Model a database Understand (Relational Database Management System)

RDBMS concept Appreciate MySQL as an open-source RDBMS

Page 3: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

Database Design

Entity-Relationship Diagram (ERD) is a tool for modeling data.

3 concepts to remember about ERD– Entity - the main object in the problem domain.– Attribute - describes the main object (entity).– Relation - association defines the between entity.

Page 4: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

Database Case StudyMayang:

I have a problem in my Resource Center

How to maintain an inventory of contact individuals and

institutions?

Wilma:

I suggest you use a DBMS to help you manage your data...

Page 5: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

Steps to Create ERD

• Identify the entity

• Identify the entity's attributes

• Identify the relation between entities

Page 6: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

• Identify the entity

PERSON INSTITUTION

Steps to Create ERD

Page 7: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

• Identify the entity's attributes 1st Form

Steps to Create ERD

PERSONNameHome addressHome phone noHome fax noEmail addressAgeSpecializationOffice namePosition heldOffice addressOffice phoneOffice fax number

INSTITUTIONNameAddressPhone numberFax numberType oforganizationArea of serviceContact persone-mail address

Page 8: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

• Identify the entity's attributes 2nd Form

Steps to Create ERD

PERSON*PersonIDTitleFirstNameMiddleInitialLastNameHomeAddress1HomeAddress2HomeCountryHomePhoneNoHomeFaxNoEmailAddressBirthdayMajorSpecializationOtherSpecializationPositionHeld

INSTITUTION*InstitutionIDNameAddress1Address2CountryPhoneNumberFaxNumberTypeOfOrganizationAreaOfServiceContactPersonEmailAddress

Page 9: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

• Identify the relation between entities

Steps to Create ERD

INSTITUTION*InstitutionIDNameAddress1Address2CountryPhoneNumberFaxNumberTypeOfOrganizationAreaOfServiceContactPersonEmailAddress

belongs to

has

PERSON*PersonIDTitleFirstNameMiddleInitialLastNameHomeAddress1HomeAddress2HomeCountryHomePhoneNoHomeFaxNoEmailAddressBirthdayMajorSpecializationOtherSpecializationInstitutionIDPositionHeld

Page 10: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

Database: Contacts

Table Name: PERSON Table Name: INSTITUTIONColumn Name Data Type Column Name Data Type*PersonID *InstitutionID

Title Name

FirstName Address1

MiddleInitial Address2

LastName Country

HomeAddress1 PhoneNumber

HomeAddress2 FaxNumber

HomeCountry TypeOfOrganization

HomePhoneNo AreaOfService

HomeFaxNo ContactPerson

EmailAddress EmailAddress

Birthday

MajorSpecialization

OtherSpecialization

InstitutionID

PositionHeld

Page 11: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

Additional DBMS Concepts

• Relational DBMS (RDBMS– Commercial RDBMS (expensive)

• Oracle, Informix, SQL Server

– GNU General Public License software (free)• MySQL, mSQL or PostGres.

Page 12: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

MySQL

• A Relational Database Management System (RDBMS) that is multi-user

• Say it as ``My Ess Que Ell". several computer workstations can access and write into a single database

Page 13: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

Where to get MySQL

• Stable version at this time is MySQL version 3.22.x.

• Asia: China [Freecode] http://mysql.freecode.com.cn China [Netfirm] http://mysql.netfirm.net Korea [KREONet] http://linux.kreonet.re.kr/mysql/ Japan [Soft Agency]

http://www.softagency.co.jp/MySQL

Page 14: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

Where to get MySQL

• Stable version at this time is MySQL version 3.22.x.

• Asia: Japan [Nagoya Syouka University]

http://mirror.nucba.ac.jp/mirror/mysql or ftp://mirror.nucba.ac.jp/mirror/mysql

Singapore [HJC] http://mysql.hjc.edu.sg or ftp://ftp.hjc.edu.sg/mysql

Taiwan [HT] http://mysql.ht.net.tw

Page 15: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

Where to get MySQL

• Stable version at this time is MySQL version 3.22.x.

• Australia: Australia [AARNet/Queensland]

http://mirror.aarnet.edu.au/mysql or ftp://mirror.aarnet.edu.au/pub/mysql

Australia [Blue Planet/Melbourne] http://mysql.bluep.com/

Australia [ITworks Consulting/Victoria] http://mysql.itworks.com.au

Page 16: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

MySQL Datatypes

• INT– can contain values up to 2147483648

•INT• INT(3)

• REAL– can contain values from-3.402823466E+38 to -

1.175494351E-38, 0 and 1.175494351E-38 to 3.402823466E+38

Page 17: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

MySQL Datatypes

• DECIMAL[(M[,D])] •DECIMAL(5,2)

• CHAR(length)– fixed character length, wastes diskspace

• CHAR(10)

• VARCHAR(length)– variable character length, economical to use

• VARCHAR(10)

Page 18: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

MySQL Datatypes

• DATE – Y2K Compliant– displays DATE values in 'YYYY-MM-DD' for

mat• TIME

– displays TIME values in 'HH:MM:SS' format• DATETIME

– displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format

Page 19: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

Recommended MySQL datatypes

• INT

• DECIMAL (M,D)

• VARCHAR(length)

• DATE

Page 20: Database Design and Creation Using MySQL Track 3 : Basic Course in Database.

Database: Contacts

Table Name: PERSON Table Name: INSTITUTIONColumn Name Data Type Column Name Data Type*PersonID INT *InstitutionID INT

Title VARCHAR(5) Name VARCHAR(200)

FirstName VARCHAR(50) Address1 VARCHAR(100)

MiddleInitial VARCHAR(3) Address2 VARCHAR(100)

LastName VARCHAR(50) Country VARCHAR(100)

HomeAddress1 VARCHAR(100) PhoneNumber VARCHAR(100)

HomeAddress2 VARCHAR(100) FaxNumber VARCHAR(100)

HomeCountry VARCHAR(50) TypeOfOrganization VARCHAR(30)

HomePhoneNo VARCHAR(100) AreaOfService VARCHAR(50)

HomeFaxNo VARCHAR(100) ContactPerson VARCHAR(100)

EmailAddress VARCHAR(100) EmailAddress VARCHAR(100)

Birthday DATE

MajorSpecialization VARCHAR(50)

OtherSpecialization VARCHAR(100)

InstitutionID INT

PositionHeld VARCHAR(100)

DA

TA

DIC

TIO

NA

RY