List sorted sort The method has a name key Parameters of
Parameters key Request to pass in a function , This function processes each item in the list , The result of processing is used as the basis for sorting
# ls /linux-soft/05
zzg_pypkgs.tar.gz
# tar xzf /linux-soft/05/zzg_pypkgs.tar.gz -C ~
# pip install pymysql_pkgs/*
Start virtual machine , install mariadb-server And start the .
Create a nsd1903 The database of , And authorize the physical host to access .
Create database
Create a database for a small company , It is used to record the basic information of employees and their salary payment .
full name 、 Gender 、 Position 、 department 、 Contact information 、 Date of birth 、 Wage day 、 Basic salary 、 Bonus 、 Paid in wages
Relational database , Data redundancy should be minimized . To eliminate redundancy , You can put data into different tables .
The employee table : full name 、 Gender 、 Position 、 department 、 Contact information 、 Date of birth
payroll : full name 、 Wage day 、 Basic salary 、 Bonus 、 Paid in wages
The paradigm of relational data
The so-called first paradigm (1NF) In a relational model , A specification requirement for domain addition , All domains should be atomic , That is, each column of the database table is an indivisible atomic data item
The contact information can be divided into :email / Phone number / Home address
Second normal form (2NF) It's in the first paradigm (1NF) Based on , That is, it meets the second norm (2NF) We must first satisfy the first paradigm (1NF). Second normal form (2NF) It is required that each instance or record in the database table can be uniquely distinguished . Simply speaking , You need a primary key .
The employee table needs to add employees ID A primary key
It is not appropriate to use any primary key for the payroll , You can add a separate id A primary key
The third paradigm is that attributes do not depend on other non primary attributes , That is to say, to satisfy 2NF On the basis of , Any non primary property must not be passed dependent on the primary property . Non primary attributes cannot depend on other non primary attributes .
In the payroll , The actual salary depends on the basic salary and bonus , It should not appear in the table , When needed , Calculate temporarily through the program .
The final table :
The employee table : staff ID、 full name 、 Gender 、 Position 、 department ID、email、phone、 Date of birth
Departmental table : department ID、 Department name