MySQL database - Student Management System Database Design

Student Management System Database Design

Design a database must first be familiar with the current system which functions, what is the specific business processes

Student Management System Features

A school student management system is used, the core functions are as follows

  1. Student Information Management (increased student, students delete, modify, students, student information queries == abbreviation: CURD)
  2. Teacher Information Management (CURD)
  3. Course Information Management System (CURD)
  4. Performance management information system (CURD)
  5. Disciplinary information management (CURD)
  6. Event Information Management (CURD)
  7. Supplies / equipment information management (CURD)
  8. Wait....

To accomplish all of the above features, the relevant information required to operate the above object information in accordance with the above objects can be stored in a fixed format in the database!
Database Design The first step is to identify the core business related objects of a class of objects / objects fixed information is stored in a table!

concept

  • Object: Life in a class of objects, a program called Object
  • Properties: nouns and adjectives describe the object, that is, the object's properties

Database design steps

Database design three core steps:

  • 1. Find an object
  • 2. find property
  • 3. To find the relationship between

Step 1: Find objects

Analysis of core business objects in the system.

  • Students Object ----> Table students (student)
  • The teacher objects ----> Teachers table (teacher)
  • Attend ----> curriculum (course)
  • Performance objects ----> results table (score)
  • Object class ----> Class Table (prefix _class, such as user or class because the English word for the program keywords. Try not directly)
  • Wait.....

Note: Some objects may be hidden because business unskilled, could not be found , such as: student written request for leave objects such as active object prior to database design ..... therefore, must take the system functions and business process consolidation clear. of course, missing objects can be replenished as needed. database design is not one step.

Step 2: looking for property

Attribute concepts: noun or adjective described object / object of study called "attributes" ,, each attribute correspondence table in a row!

  • Students Object (student): uniquely identifies the id, student number name, sex, age, date of birth, telephone,
  • Object teacher (teacher): uniquely identifies the id, name, gender, age, phone
  • Target Audience (course): a unique identification id, course name, start time, the number of hours
  • Class objects (tbl_class): uniquely identifies the id, class number, the number of
  • Performance target (score): id, score, course name (course code can be directly quoted), student name (can be a direct reference to student number)

Each object attributes correspond to each column of the table
in order to avoid data redundancy (repetition), instead of the name and curriculum with student id id!
Computer data storage is strictly distinguish between different types of ages:! Integer int, name: Character string; char / varchar / string

Step 3: looking for relationships

The relationship between the table and the table has: 1 --- N (1 to many) or N --- 1 (a plurality of) or 1-1 (1 to 1) or N - N (many)

  • 1-1 or 1-N or N-1: indicated by the primary and foreign keys
  • NN: a many-but appear to be implemented by means of an intermediate table (table)
  • Such as commodities and order form is N - N
    • Goods (id, product number, name, quantity, price)
    • Orders (id, order number, user name (id), the total price of the total number)

A separate intermediate table / table (table A primary key of the other two reference)

id pid (product number) oid (order number)
1 P001 D001
2 P002 D001
3 P003 D001
4 P001 D002
5 P001 D003
6 P002 D002
#查  订单D001买的所有的商品!
select * from 表名   where oid='D001'
# 查 商品  P001被下单了多少次?
select * from 表名  where pid = 'P001'

#  看:D001 买了几个商品!
select sum(num) from guanxi_product_order
where oid='D001'

Principle to build the table

After analysis of the object can be built out of the table, the general principle to follow when construction of the table below.
To build the table rules

  • 1. The same type of object information is stored in a table!
  • 2. Each object attribute corresponding to each column of the table!
  • 3. In the column data type specific
    • int: integer
    • Decimal: float / doube
    • Date: date.datetime
    • String: char / varchar
  • 4. Each table must have a primary key column!
    • The only distinction between a row on the column cross-primary key column (which may be a plurality)
    • Rules: In order to avoid no primary key used to add a virtual primary key id (increment)
  • 5. Add constraints (limits)
    • Primary key: primary key ---> Features: Unique
    • Increment: auto_increment ----> automatic growth
    • Default value: default -----> defaults to male gender!
    • Non-null: null --------> must have data not
    • Unique: unique ----> can not be repeated
    • foreign key foreign key (reference): ------> score table storage class id, course id,

Step 4: Find a special case: Level obvious and does not contain sensitive data information is recommended to keep a watch

For example: Regional tables and table staff

id (area code) name code pcode Parent Number
1 Beijing 11
2 Shandong 37
3 Jinan 3701 37
4 Qingdao 3702 37
5 Haidian 1101 11
6 Fangshan 1102 11
-- 所有省
select * from area where pcode is null

-- 山东省所有的市
select code from area where name= '山东'
select * from area where pcode = 37

select * from area where pcode = (
 select code from area where name= '山东'
)

Follow the database design of the three paradigms

  • The first paradigm: atomicity
    based on business needs to ensure that every column in the table can not be subdivided for example: Simple Storage student information is enough to use, but the address listed electricity supplier websites addresses need to be split into provinces, cities and counties. rural
  • The second paradigm: Correlation between
    each column and are guaranteed table associated primary key , as long as a class of the object information is stored in a table, it satisfies a second paradigm
  • Third paradigm: a direct correlation to
    the plurality of columns are generally used as a joint intermediate the primary key, and other columns must be directly related to each component, and not only has one column relationship.

参考:https://www.cnblogs.com/knowledgesea/p/3667395.html

Summary: Database design follows the principle [focus]

Premise: familiar with the business processes of project!

  • A class object information stored in tables
  • Table must have a primary key column (in order to prevent the primary key is not used to add a virtual primary key column id, id usually set to increment)
  • Add constraints to ensure data integrity
    • Primary key
    • only
    • Increment
    • non empty
    • Foreign key (to achieve 1-N)
    • Defaults
  • A plurality of pairs must be independent table
  • Note: Level clear and no sensitive information from the associated data can be achieved!
  • Compliance: database design three paradigms (three principles)

Guess you like

Origin www.cnblogs.com/bignote/p/11610070.html