当前位置:网站首页>Unity and database
Unity and database
2022-07-05 04:52:00 【yaohuiyaoo】
mount this database ——》 Connect your own computer host ——》 Create database
One . Database design
1. In database design , How to represent the relationship between databases ?
relational model
2. Entity set X and Y What kinds of relationships exist ?
One to many , one-on-one , For one more , Many to many
3, What are the functions of the three paradigms of database ?
The goal of the first paradigm is to ensure the atomicity of each column
The second formula requires each table to describe one thing
If the first relationship satisfies 2NF, Besides, columns other than primary keys do not pass dependent primary keys
4, Database design in the project development cycle
Demand analysis stage : Analyze customers' business and data processing requirements
Outline design stage : Design database E-R Model diagram , Confirm that the requirement information is correct and complete
Detailed design stage : Apply three paradigms to audit database structure
Code writing phase : Physically implement the database , Writing and implementing applications
Software testing phase :
Installation and deployment :
5 draw E-R chart
The symbol rectangle is an entity
The symbol ellipse is an attribute
Square is relation
Two . Add, delete, change and check the database
1. Login database command :mysql -h( Server host address ( This machine can omit ))-u( user name ) -p( password ); Note that the content in brackets is the content required in the brackets immediately after
2. Create database :create database Database name ;
3. View all databases :show databases;
4. Access to database :use Database name ; // The entered database can only be existing
5. Delete database :drop database Database name ;
Be careful :. After entering the data, you can modify and add the data in the table
6. Create table :create table Table name ( Field 1 data type [ Field properties ][ constraint ][ Indexes ],…);
Field constraints
Non empty constraint not null Field cannot be empty
Default constraint default Assign the default value of a field
Unique constraint unique key Set the unique value of the field , Allow null , But only one can be empty
Primary key constraint primary key Set the field as the primary key of the table , It can uniquely identify the record of this table
Foreign key constraints foreign key Used to establish a relationship between two tables , You need to specify which field of the main table to refer to
Automatic growth auto_increment Set the column as a self incrementing field , By default, each self increment 1, Usually used to set the primary key
7. See if the table exists :use Table name
8. View all tables :show tables;
9. Check the parameters in the table :desc Table name ;
10 Delete table :drop table Table name ;
11. insert data :insert into Table name ( Field 1, Field 2, Field 3)value( data 1, data 2, data 3)
12. Modifying data :update Table name set Field 1= Revised data where Field = data
Be careful : Satisfy where The data matching will be modified later
13. Delete data :delete from Table name where Field = data
Be careful : Satisfy where The following conditions will be deleted
3、 ... and unity Use database under
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MySql.Data.MySqlClient;
public class Test2 : MonoBehaviour {
void Start () {
Startdata();
}
void Startdata()
{
string a = "server=localhost;database=student;userid=root;password=root";
//serveer= Host name database= Database name userid= user name password= password
// Create objects that connect to the database
MySqlConnection con = new MySqlConnection(a);// Connect data
// Open the connection
con.Open();
// Specific statements for table operations
string sql = "insert into xinxi(name,sex,age) value(' drug ',' male ',18)";//"insert into Table name ( Field 1, Field 2, Field 3) value( data 1, data 2, data 3);
// Create operands
MySqlCommand com = new MySqlCommand(sql, con);// Execute the operation statement on the table
if (com.ExecuteNonQuery() > 0)
{
print(" success ");
}
// Query the contents of the table
string selec = "select *from xinxi";// Query statement
MySqlCommand cad = new MySqlCommand(selec, con);
MySqlDataReader reader = cad.ExecuteReader();
while (reader.Read())
{
int id = reader.GetInt32("id");
string name = reader.GetString("name");
string sex = reader.GetString("sex");
print(id + "\t" + name + "\t" + sex);
}
reader.Close();
con.Close();
}
}
边栏推荐
- 2020-10-27
- Difference between singleton and factory pattern
- Solution of circular dependency
- 中国针状焦行业发展研究与投资价值报告(2022版)
- 猿人学第一题
- Research and investment forecast report of adamantane industry in China (2022 Edition)
- 3dsmax common commands
- AutoCAD - workspace settings
- Download the details and sequence of the original data access from the ENA database in EBI
- China needle coke industry development research and investment value report (2022 Edition)
猜你喜欢

CUDA Programming atomic operation atomicadd reports error err:msb3721, return code 1

Wenet: E2E speech recognition tool for industrial implementation

Decryption function calculates "task state and lifecycle management" of asynchronous task capability

54. Spiral matrix & 59 Spiral matrix II ●●
![[groovy] closure (closure call | closure default parameter it | code example)](/img/61/754cee9a940fd4ecd446b38c2f413d.jpg)
[groovy] closure (closure call | closure default parameter it | code example)

Flutter 小技巧之 ListView 和 PageView 的各种花式嵌套

Create a pyGame window with a blue background

2022-2028 global and Chinese FPGA prototype system Market Research Report
![[groovy] closure (closure as function parameter | code example)](/img/a6/a4ed401acfb61f85eb08daa15a8a80.jpg)
[groovy] closure (closure as function parameter | code example)

2022 thinking of mathematical modeling D problem of American college students / analysis of 2022 American competition D problem
随机推荐
【acwing】528. cheese
Group counting notes (1) - check code, original complement multiplication and division calculation, floating point calculation
Leetcode 222 number of nodes of complete binary tree
#775 Div.1 B. Integral Array 数学
[groovy] closure (closure call is associated with call method | call () method is defined in interface | call () method is defined in class | code example)
AutoCAD - full screen display
Establish cloth effect in 10 seconds
775 Div.1 C. Tyler and strings combinatorial mathematics
Wenet: E2E speech recognition tool for industrial implementation
Use assimp library to read MTL file data
JMeter -- distributed pressure measurement
The principle of attention mechanism and its application in seq2seq (bahadanau attention)
MD5 bypass
Rip notes [rip three timers, the role of horizontal segmentation, rip automatic summary, and the role of network]
2021 higher education social cup mathematical modeling national tournament ABCD questions - problem solving ideas - Mathematical Modeling
2022 thinking of mathematical modeling a problem of American college students / analysis of 2022 American competition a problem
2022-2028 global and Chinese virtual data storage Market Research Report
PostgreSQL surpasses mysql, and the salary of "the best programming language in the world" is low
3dsmax common commands
Emlog博客主题模板源码简约好看响应式