MySQL Database utf-8 encoding

Source: Internet
Author: User

Database design

Multimedia websites, small programs, mobile development are inseparable from the background system, must use the database.

The database design consists of four main steps:

1. Demand Analysis

The main results are: Requirements Analysis documentation

Entities (objects), contact

There are three kinds of contact: 1-1, 1-*, *-*

2. Conceptual design (E-r map)

3, logical design (table): At least 3NF compliance

(1) Each entity corresponds to a single table

User table: number , name, type

Book list: number , ISBN, name, price, publisher

(2) More-long, the relationship also corresponds to a table

User-book list: User number, book number

4. Physical Design

Take MySQL for example:

DROP DATABASE IF EXISTS Books;

CREATE DATABASE Books;

Use books;

SET Collation_database=utf8_general_ci;

SET Collation_connection=utf8_general_ci;

SET Collation_server=utf8_general_ci;

ALTER DATABASE Books CHARACTER SET UTF8;

DROP TABLE IF EXISTS tuserbook;

DROP TABLE IF EXISTS TUser;

DROP TABLE IF EXISTS tbook;

CREATE TABLE TUser (

Code VARCHAR (16),

Username VARCHAR (64),

Password VARCHAR (64),

Utype VARCHAR (1),

PRIMARY KEY (Code)

);

CREATE TABLE Tbook (

Code VARCHAR (16),

Name VARCHAR (64),

ISBN VARCHAR (32),

Price float,

Publish VARCHAR (32),

PRIMARY KEY (Code)

);

CREATE TABLE Tuserbook (

ID INT (one) PRIMARY KEY auto_increment,

Usercode VARCHAR (16),

Bookcode VARCHAR (16),

FOREIGN KEY (Usercode) REFERENCES TUser (code)

On DELETE CASCADE

On UPDATE CASCADE,

FOREIGN KEY (Bookcode) REFERENCES Tbook (code)

On DELETE CASCADE

On UPDATE CASCADE,

);

Database modeling Tools:

PowerDesigner

MySQL Database utf-8 encoding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.