Vb. NET Edition computer room charge system-Database design

Source: Internet
Author: User

before the first time the computer room charges, using the database is someone else's, cognition can only be built on the basis of others, such as the "database system principle" after learning the book, then go to the previous database, found that the database really need further optimization, the following is my design database of some ideas, I hope you will make some more comments.

Database Designe-r Model:

In the design stage of conceptual model, a system is built on ER model, it is very important to design ER model.

I designed the ER diagram:


entities in the system: it is very simple, that is, the system of the nouns are abstracted out, and then specific is converted to the logical design of the database to be considered. contact in the system: you can see clearly in the diagram, here I want to focus on:

(1) I separate the t_student table from the T_card table because the previous design violates the third paradigm, and why is the student and card number a one-to-one relationship? Because my design idea is: A student can only have a card to be able to use normally, other, for example, the student loses the card, before that card can not use, but the card table inside still will save this not to use card information, therefore, card-table and student table separate, but a student can only use one card.

(2) This design, the previous Line table and online table and as a table T_online table, figure 1, the previous onwork and Wordlog table is a table T_wordlog table, figure 2 shows , delete the Checkweek table (as with the Checkday table, only the query conditions are different.) )




The T_line table after design:


Figure 1



The T_wordlog table after design:


Figure 2

ER contact: System er diagram, can very clearly see the connection between them, there are 1 pairs of more than 1, many to many, this relationship must be clear, even if you and others are not the same, no relationship, because the design, the idea is not the same, will produce different effects.

Properties of ER: see later relationship model.

In fact, the design of ER diagram, actually, er design out of time, a lot of people have different ideas, for example, some people say my student table and card table separate will be very messy, registration, to separate registration, very complex. I think we can try each other, the benevolent see! As long as others ask, give yourself a statement on the line.

Relational Model:

The main component in ER diagram is entity type and contact type, and the conversion algorithm is how to convert entity type and contact type into contact mode.

er entity type conversions: (All rectangles in the ER diagram are entities and can be built into tables):

T_basicdata (Rate,tmprate,unittime,leasttime,preparetime,limitcash,head)

T_card (cardno,registerdatetime,cacnceldatetime,cash,head,type,status) t_student (studentno,cardno,studentname,age,sex,department,grade,class,date,time,explain)

T_user (Userid,sername,level,password,computer,head)

t_checkday (lastcash,head,recharge,cancelcash,consumecash,nowcash,computer,status) T_wordlog (userid,level,logindate,logintime,logoutdate,logouttime,computer,status)

er Relationship transformation:

For 1:1 relationships, the T_student table can include Cardno fields (Studentno as the primary key and Cardno as the foreign key).

For 1:n relationships, the attribute values can be added appropriately.

For n:m relationships, relationships are a pattern (blue Diamond t_line and T_recharge)

T_line (Cardno,head,onliendatetim,outlinedatetime,consumetime,consume,computer,status)

T_recharge (Cardno,head,recharge,datetime,ischeck)

All right, look, it's good enough to meet the requirements of the three paradigms:

The first paradigm: attribute is not divided, in fact, it is easy to see that the property value can only be multiple single-valued properties.

The second paradigm: to eliminate part of the dependency, this one is easily disrupted by the function, because many people are based on the function to arrange the attributes, here can do so, after doing, check, there is no local dependency, remove on the line.

The third paradigm: elimination of transmission dependence, this has to take a good look at, to the previous student table and card table into a table in fact there is a transmission dependency, separate on the right.

Design Database:

The main thing is to pay attention to the data type, this still need to look at the code, my first version of the system d all the DateTime, is the datetime such data type, in the vb.net must see if there is a problem.

In conclusion, we should learn to apply we learn the knowledge, I learn the database is too shallow, a lot of is still built on the basis of the original database, but I believe that when we study hard, bold try, or soon will have a harvest, the above database is just a few personal ideas, there is better, we share, exchange.




Related Article

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.