A Discussion on System Modeling (I)

Source: Internet
Author: User

Preface

I wrote an article in the field of system modeling, which was written with an uneasy mood and did not dare to insult the thinker in this field, becauseGood working ideas/models in specific scenarios may fail badly in other scenarios. If there is a commonly used method/mode, the software will only provide support for this method/mode. Why bother?

Before talking about complicated time modeling cases, let's take a look at a simple system model. There is no need for time latitude. Let's look at the issues that need to be considered. I used it in an OA product ten years ago. Because of product thinking, I used the following common data models to maximize flexibility ", the modeling results expressed using SQL statements are as follows:

/* Tables that store class instances (objects). Each object is represented by a record in this table */

Create Table objects (OID int primary key, name varchar2 (255 ));

/* Stores the table defined by class attributes. Each attribute is represented by a record in this table */

Create Table attributes (attrid int primary key, attrname varchar2 (255), datatype varchar2 (25 ));

/* Tables that store class instances (objects). Each attribute of each object is represented by a record in the table */

Create Table object_attributes (OID int, attrid int, value varchar2 (255), primary key (OID, attrid ));

My wife appreciates Tom Hans very much. To express movie stars, the demonstration model is as follows:

/* In the attributes table, three records are as follows */

Insert into attributes values (1, 'birthdate', 'date ');

Insert into attributes values (2, 'firstname', 'string ');

Insert into attributes values (3, 'lastname', 'string ');

/* Objects and object_attributes have 1 and 3 data records respectively */

Insert into objects values (1, 'movie star ');

Insert into object_attributes (1, 1, '2017-07-09 ');

Insert into object_attributes (1, 2, 'Tom ');

Insert into object_attributes (1, 3, 'hans ');

A person with a high level of SQL statements can write the statements found by movie stars. Haha, it looks good. This kind of flexibility is great, especially in the OA system, you need to support custom form fields. Readers, what do you say about this model and how should we judge it?

What is time modeling? 

On the last day of the 08 S, colleague Z talked about the problems in system R. After inquiry, I know that the model that the system R needs to express requires time modeling. What is time modeling? For example, in the user management model of the IT system, express the Department relationship between users and the organizational structure, it is enough to use the 1-0 relationship (why can't the database express the model? In this scenario, we should use the 1-0 relationship ). However, if you are building a human resource management system, you must not only manage H's services in the industry center, but also record that H was in the net application Department before May, train new employees in the HR department from January 1, July to January 1, September. If your model needs to express such problems, it is time modeling.

How is system R modeled?

In terms of presentation time modeling in system R, the begin_time and end_time attributes are added to the application physical table. In the preceding example, begin_time and end_time are added to the USERPROFILE table. Of course, in the deptprofile table, begin_time and end_time are also added in response.

Other declared integrity constraints are also used during modeling, including begin_time not null, check (end_time is null) or (end_time> = begin_time ). Some readers have already discovered that, for an object that requires time modeling, the record is not deleted, but only added and modified. The primary key USERID/deptid is a value-added sequence. Some readers may ask, are there any foreign key relationships between the userprofile and the deptprofile physical table of the Organization? The answer is creation.

Of course, some readers already know this model, and declared consistency expressions have different logical meanings from the real world. For example, the system allows record personnel h to make valid records from January 1, May 1 to the present (USERPROFILE Record ID = 2198/begin_time = 2008-05-01/end_time = NULL) reference Department net (deptprofile Record ID = 654/begin_time = 2004-03-01/end_time = 2008-03-01, from the record, this department has been canceled currently ). Of course, in order to ensure the value of the data itself, the above logic guarantee must also be ensured by the application or the middle layer.

To access the data valid for the current time now, you must filter out the deptprofile history and new records that have not yet taken effect. For example, this department has been working since January 1, March 1 (remember that it is now January 1, February 7 ), therefore, the filter condition is: begin_time <= sysdate and (end_time is null or end_time> sysdate ). Using the above filter conditions in system R, some view views are created to express the current valid record.

This modeling method of system R is a common model used by many IT design and development colleagues in the face of time modeling problems. In this general mode, there is also a sufficient flexibility to express the minimum granularity of time can be fine-tuned to the database to express the minimum interval of the datetime type. If you use this method in a similar time model, do you have any side effects or problems?

(To be continued)

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.