Example: fk_user_info_DEPARTMENT_DEPTID (create foreign key on the table user_info field department_ID, refer to the main table department)
N) synonym (Oracle)
The naming format of synonyms is: SY_
Example: SY_USER_INFO (public meaning of the table USER_INFO belonging to ownership)
7 script comments
7.1 Storage Process or Trigger
a) Each stored procedure or trigger must write a comment in the forefront, the comment is as follows
/ *
Writer:
Create Date:
VER:
Depiction:
REMARK:
* /
In addition, important variables declared in the process must be annotated, for example:
@iactionflag int = 0 / * 0 => Checkout, 1 => getlatest, 2 => undocheckout * /
b) If you only have some modifications to the stored procedure or trigger, you must add the following notes:
/ * REWRITER: ADD (REWRITER): DATE:
Modify description:
* /
/ * Original code content * / (modified)
/ * REWRITER: DATE:
/ * REWRITER: Add (REWRITER): Date:
New code content
/ * REWRITER: DATE:
c) If there is a large modification for the stored procedure or trigger, you can increase the comment of the modified content.
/ * Log ID:
REWRITE DATE:
Depiction:
* /
7.2 Custom Function
a) Each custom function must write a comment in front of it, the comment is as follows
/ *
Function name: XXXX
Depiction: Description of this function>
PARAM (A, B)
A function or description ....
B function or description
Output: x x = 0 means ..... x = 1 means ......
Writer:
Create Date:
VER:
REMARK:
* /
In addition, the important variables declared in the function should be annotated, for example:
@iactionflag int = 0 / * 0 => Checkout, 1 => getlatest, 2 => undocheckout * /
b) If only partially modify the function, you must add the following notes:
/ * REWRITER: ADD (REWRITER): DATE:
Modify description:
* /
/ * Original code content * / (modified)
/ * REWRITER: DATE:
/ * REWRITER: Add (REWRITER): Date:
New code content
/ * REWRITER: DATE:
c) If there is a large modification to the function, you can increase the comment for modifying the content.
/ * Log ID:
Rewriter:
REWRITE DATE:
Depiction:
* /
8 database operation principle
8.1 Establish, delete, and modify library table operations
Ø In the development environment, you can modify your own library table, delete the operation;, you need to retain the corresponding schedule statement and instructions, and build a table with the table.
8.2 Add, delete, modify table data
Ø In the development environment, the developer's development module is alone in the library table that is free to operate;
Ø The library table associated with other modules should obtain the developer of other modules to agree to execute the operation; Ø System information table, Dictionary table modification should make operational requirements to the administrator of the database, and perform operations by the administrator of the database.
9 common field name
9.1 System Information Common Field
Field Name
Field code
Oracle
SQLServer
value
Description
User ID
User_id
Char (8)
Char (8)
Used to log in to the application system, fill in the number. Generally, the primary key is to be filled with the length.
user name
User_name
VARCHAR2 (20)
VARCHAR (20)
User ID corresponding name
Group identification
GRP_ID
Char (4)
Char (4)
The group identifier to the user belongs, fill in the number. Generally, the primary key is to be filled with the length.
Group name
GRP_NAME
Varchar2 (50)
VARCHAR (50)
Group identification corresponding name
Order rights logo
GRP_AUTH_ID
Char (2)
Char (2)
From low to high, from 00 to 99. To fill the length
Order rights name
GRP_AUTH_NAME
Varchar2 (50)
VARCHAR (50)
Group permission logo corresponding name
password
Password
VARCHAR2 (30)
VARCHAR (30)
9.2 Customer personal information common field
Field Name
Field code
Oracle
SQLServer
value
Description
Customer logo
Customer_ID
char (?)
char (?)
The customer identifier used by the business system, generally the primary key, does not need to grow long types. To fill the length.
Customer Name
Customer_name
Varchar2 (50)
VARCHAR (50)
Department identification
DEPT_ID
char (?)
char (?)
Generally, the primary key is generally used. To fill the length.
Department name
DEPT_NAME
Varchar2 (50)
VARCHAR (50)
gender
SEX
char (1)
char (1)
F / m
The following is not identified, fill in the specific value directly in the field.
marital status
Marriagestatus
Varchar2 (50)
VARCHAR (50)
date of birth
Birthday
date
SmallDateTime
height
hight
Number (5, 2)
DEC (5, 2)
Unit is centimeter
body weight
Weight
Number (5, 2)
DEC (5, 2)
Unit is kg
Nation
Nationality
VARCHAR2 (20)
VARCHAR (20)
contact number
Phone
Varchar2 (50)
VARCHAR (50)
home phone
Home_phone
Varchar2 (50)
VARCHAR (50)
Office phone 1
Office_phone1
Varchar2 (50)
VARCHAR (50)
Office phone 2
Office_phone2
Varchar2 (50)
VARCHAR (50)
Area code
zone
VARCHAR2 (20)
VARCHAR (20)
fax number
Office_fax
Varchar2 (50)
VARCHAR (50)
mobile phone
MOBIL_PHONE
Varchar2 (50)
VARCHAR (50)
Varchar2 (50)
VARCHAR (50)
Postal code
POST_CODE
VARCHAR2 (20)
VARCHAR (20)
Country of Citizenship
COUNTRY
Varchar2 (50)
VARCHAR (50)
Residential province
province
VARCHAR2 (20)
VARCHAR (20)
Residential city
CITY
VARCHAR2 (20)
VARCHAR (20)
Home address
HOME_ADDR
VARCHAR2 (80)
VARCHAR (80)
Office location
Office_addr
VARCHAR2 (80)
VARCHAR (80)
Document number
CERT_NUMBER
Varchar2 (50)
VARCHAR (50)
the name of your ID
CERT_NAME
VARCHAR2 (20)
VARCHAR (20)
Career logo
Occupation_id
Char (4)
Char (4)
To fill the length
Carement name
Occupation
Varchar2 (50)
VARCHAR (50)
education level
education
VARCHAR2 (20)
VARCHAR (20)
9.3 Quick information common field
Field Name
Field code
Oracle
SQLServer
value
Description
Record status identification
Flag
char (1)
char (1)
A / D ...
A: effective; D: Delete; S: Pause ...
Record serial number
id
Number
int
9.4 Business information common field
Field Name
Field code
Oracle
SQLServer
value
Description
Business date
Oper_date
date
Smalldate
start date
Begin_date
date
Smalldate
End date
END_DATE
date
Smalldate
Operation date
Curr_date
date
Smalldate
Operator number
User_id
Char (4)
Char (4)
That is, the user ID in system information
Increasing
Number (7, 2)
DEC (7, 2)
Balance
Balance
Number (10, 2)
DEC (10, 2)
description
Description
Varchar2 (50)
VARCHAR (50)
10 Design instance (SQL Server 2000)
10.1 Table, primary key, foreign key, index, rule, constraint
Name: t_base_user
Chinese Name: User Basic Information Form
Simply explained: Store user basic information
name
Code
type of data
Key, rules, constraint
Comment
User ID
User_id
Char (8)
PK
User unique identity
username
User_name
VARCHAR (20)
User real name
height
hight
Decimal (7, 2)
RL_NOT_ZERO
To give examples, this three fields are set, the original table is not.
body weight
Weight
Decimal (7, 2)
start date
Begin_date
SmallDateTime
DF_BEGIN_DATE
Department ID
Department_id
Char (4)
Fk
The department ID to which the user belongs
Refer to the main table: department
User duties 1ID
HEADSHIP1_ID
Char (4)
Fk
User's position ID
Refer to the main table:
User duties 2ID
Headship2_id
Char (4)
Fk
User's position ID
Refer to the main table:
User title ID
Title_id
Char (4)
Fk
User title ID
Refer to the main table:
telephone number
Phone
VARCHAR (50)
User phone number
VARCHAR (50)
Bank Account
Account_no
VARCHAR (50)
User's salary bank account
Identity ID
CERT_NUMBER
VARCHAR (30)
Uni index
User identity ID
Deactivate
Flag
char (1)
NOT NULL
Identify whether the user is canceled
/ * ================================================================================================================================================================ =============== * /
/ * Table: t_base_user * /
/ * ================================================================================================================================================================ =============== * /
CREATE TABLE T_BASE_USER (
User_id char (8) Not null,
User_name varchar (20) NULL,
High Decimal (7,2) NULL,
Weight Decimal (7, 2) NULL,
Begin_Date SmallDateTime Null,
Department_id char (4) NULL,
Headship1_id char (4) NULL,
Headship2_id char (4) null,
Title_id char (4) NULL,
Phone varchar (50) NULL,
Email varchar (50) NULL,
Account_no varchar (50) NULL,
Cert_number varchar (30) NULL,
Flag char (1) NULL,
ConsTRAINT CK_FLAG CHECK (Flag Between '0' and '9'),
ConsTRAINT PK_USER_BASE_USERID PRIMARY Key (user_id)
)
Go
/ * ================================================================================================================================================================ =============== * // * index: idx_cert_number * /
/ * ================================================================================================================================================================ =============== * /
CREATE UNIQUE INDEX IDX_CERT_NUMBER ON User_Base (CERT_NUMBER)
Go
/ * ================================================================================================================================================================ =============== * /
/ * FOREIGN Key: fk_user_base_department_depid * /
/ * ================================================================================================================================================================ =============== * /
ALTER TABLE User_Base
Add constraint fk_user_base_department_depid foreign key (department_id)
References Department (Department_ID)
Go
...
(Note: The above statement assumes that the main table name is DEPAERMENT. Create other foreign keys according to this statement)
/ * ================================================================================================================================================================ =============== * // * Binding rules rl_not_zero to the list of User_Vases Hight * /
/ * ================================================================================================================================================================ =============== * /
EXEC SP_BINDRULE 'DBO.RL_NOT_ZERO', 'USER_BASE.HIGHT'
/ * ================================================================================================================================================================ =============== * /
/ * Bind default DF_BEGIN_DATE to table USER_BASE column begin_date * /
/ * ================================================================================================================================================================ =============== * /
EXEC SP_BINDEFAULT 'DBO.DF_BEGIN_DATE', 'User_Base.Begin_Date'
Annex 1: Database Dictionary Dictionary
Name: t_base_user
Chinese Name: User Basic Information Form
Simply explained: Store user basic information
name
Code
type of data
Foreign bond
(Foreign key)
Mandatory
(constraint)
Main (primary key)
Comment
User ID
User_id
Char (8)
True
True
User unique identity
User_name
VARCHAR (20)
User real name
Department ID
Department_id
Char (4)
True
The department ID to which the user belongs
Refer to the main table: department
User duties 1ID
HEADSHIP1_ID
Char (4)
True
User's position ID
Refer to the main table:
User duties 2ID
Headship2_id
Char (4)
True
User's position ID
Refer to the main table:
User title ID
Title_id
Char (4)
True
User title ID
Refer to the main table:
telephone number
Phone
VARCHAR (50)
User phone number
VARCHAR (50)
Bank Account
Account_no
VARCHAR (50)
User's salary bank account
Identity ID
CERT_NUMBER
VARCHAR (30)
User identity ID
Deactivate
Flag
Char (1)
True
Identify whether the user is canceled
Programs: PK_BASE_USER_USERID
Outer key: fk_base_user_Department_DepID, ...
Attachment 2: Database Type Short
serial number
database
Type short
1
Sybase
SYB
2
Oracle
ORA
3
DB2
DB2
4
SQL Server
SQL