Database three paradigm

Source: Internet
Author: User
The following describes the first three paradigms:
I. First paradigm. It is a basic requirement for the relational model. databases that do not meet the first paradigm are not relational databases. The first example indicates that each column in a database table is an inseparable basic data item. The same Column cannot contain multiple values, that is, an attribute in an object cannot have multiple values or duplicate attributes. If duplicate attributes exist, you may need to define a new object. A new object consists of duplicate attributes. The new object has one-to-multiple relationships with the original object. This single attribute is composed of basic types, including integer, real number, complex type, logical type, and date type. For example, if there is a table that stores files, it should be like this: You can see that this table contains several columns, if we put all the information in a column, the 1nf defined above will not be satisfied.

Create Table Regulations (
Id int identity,
Title nvarchar (200) null,
Fileaddress varchar (255) null,
Opendate datetime null,
Typeid int null,
Postdate datetime null,
Constraint pk_regulations primary key (ID)
)

Ii. Second paradigm: built on the basis of the first paradigm. Each instance or row in the database table must be divided by a unique region. You usually need to add a column to the table to store the unique identifier of each instance. This unique attribute column is called as the primary keyword, primary key, and primary code. As shown in the preceding regulations, the ID column is an identity column ).

Iii. Third paradigm: a database table must not contain non-primary keywords that have already been included in other tables. For example, there is a file table regulations on it. If this table is the primary file for storage and there are n attachments, we need to create another attachment table to store the attachments. How can we associate the two tables? We can insert the primary key of the main file table along with the attachment information as a record into the attachment table. The information inserted here only contains the primary key ID, without inserting other information, this relationship satisfies the requirements of the third paradigm.

Create Table attachment (
Id int identity,
Fileid int null, // primary key ID of the primary file
Address varchar (255) null,
Title nvarchar (200) null,
Constraint pk_attachment primary key (ID)
)

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.