日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

关系型数据库的核心单元是_核中的数据关系

發(fā)布時間:2023/11/29 数据库 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 关系型数据库的核心单元是_核中的数据关系 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

關(guān)系型數(shù)據(jù)庫的核心單元是

Nucleoid is an open source (Apache 2.0), a runtime environment that provides logical integrity in declarative programming, and at the same time, it stores declarative statements so that it doesn’t require external database, in short it can be used as database.

Nucleoid是一個開放源代碼(Apache 2.0),它是一個運(yùn)行時環(huán)境,可在聲明式編程中提供邏輯完整性,同時,它存儲聲明性語句,因此不需要外部數(shù)據(jù)庫,總之可以用作數(shù)據(jù)庫。

數(shù)據(jù)結(jié)構(gòu) (Data Structure)

Data structures are defined in declarative syntax. Let’s say name is a variable, and by program requirements, name must be:

數(shù)據(jù)結(jié)構(gòu)以聲明性語法定義。 假設(shè)name是一個變量,并且根據(jù)程序要求, name必須為:

  • less than 10 characters

    少于10個字符
  • first character is upper case

    第一個字符為大寫
  • contains no underscore character

    不含下劃線字符

so, this can be 3 separate declarations:

因此,這可以是3個單獨(dú)的聲明:

> if( name.length > 10 ) {
throw "INVALID_SIZE"
}> if( ! /[A-Z]/.test( name.charAt(0) )) {
throw "INVALID_FIRST_CHARACTER"
}> if( name.indexOf("_") > -1 ) {
throw "INVALID_SPECIAL_CHARACTER"
}

人際關(guān)系 (Relationships)

Relationships of objects are defined similar to database’s relationships, but it requires to define in declarative syntax.

對象的關(guān)系的定義與數(shù)據(jù)庫的關(guān)系類似,但是需要使用聲明性語法進(jìn)行定義。

一對一 (One-to-One)

One-to-one’s defined as referring object’s property to another object instance.

一對一的定義是將對象的屬性引用到另一個對象實(shí)例。

> class Driver {}
> class Vehicle {}> driver1 = new Driver();
> vehicle1 = new Vehicle();
> driver1.vehicle = vehicle1;

Bidirectional relationships requires additional declaration in order to keep both side synced, so not recommended unless absolutely required, associative entity may be used as alternative.

雙向關(guān)系需要額外的聲明才能使雙方保持同步,因此除非絕對必要,否則不建議使用關(guān)聯(lián)實(shí)體作為替代。

Still all the declarations are applicable to the property:

所有聲明仍然適用于該屬性:

> Vehicle.type = "CAR"
> driver1.vehicle.type
"CAR"

一對多 (One-to-Many)

One-to-Many is defined in three ways:

一對多定義有以下三種方式:

列在身邊 (List as in One’s side)

It is a list created as property:

這是一個創(chuàng)建為屬性的列表:

> class Customer {}
> class Order {}> Customer.orders = [];> customer1 = new Customer();
> order1 = new Order();
> customer1.orders.push(order1);

像Manys一樣的財產(chǎn) (Property as in Many’s side)

It is a property created, which refers to other instance:

這是一個創(chuàng)建的屬性,它引用其他實(shí)例:

> class Employee {}
> class Project {}> employee1 = new Employee()
> project1 = new Project();
> project1.employee = employee1;

Both of first 2 options are not bidirectional.

前兩個選項(xiàng)都不是雙向的。

關(guān)聯(lián)實(shí)體 (Associative Entity)

In this case, both objects will be registered in associative object:

在這種情況下,兩個對象都將被注冊到關(guān)聯(lián)對象中:

> class User {}
> class Company {}
> class Registration {}> if ( Registrations.filter( r => r.user == User ).length > 1 ) {
throw "USER_ALREADY_REGISTERED"
}> user1 = new User();
> company1 = new Company();> registration1 = new Registration();
> registration1.company = company1;
> registration1.user = user1;

Having a declaration of if ( Registrations.filter( r => r.user == User ).length > 1 ){ .. } adds One-to-Many constraint. In this case, registering user1 to another company throws "USER_ALREADY_REGISTERED":

如果聲明為if ( Registrations.filter( r => r.user == User ).length > 1 ){ .. }添加一對多約束。 在這種情況下,向另一家公司注冊user1會引發(fā)"USER_ALREADY_REGISTERED" :

> company2 = new Company();
> registration2 = new Registration();
> registration2.company = company2
> registration2.user = user1;
> "USER_ALREADY_REGISTERED"

多對多 (Many-to-Many)

Many-to-Many is relatively straightforward as only possible with associative entity without carrying any additional constraint.

多對多是相對直接的,只有在沒有任何附加約束的情況下,才可能具有關(guān)聯(lián)實(shí)體。

> class Passenger {}
> class Flight {}
> class Ticket {}> passenger1 = new Passenger();
> flight1 = new Flight();> ticket1 = new Ticket();
> ticket1.passenger = passenger1
> ticket1.flight = flight1;> flight2 = new Flight();> ticket2 = new Ticket();
> ticket2.passenger = passenger1
> ticket2.flight = flight2;

查詢 (Queries)

Queries is done with functional programming.

查詢是通過函數(shù)式編程完成的。

The runtime stores each instance into its class list like driver1 = new Driver() will be part of Drivers.

運(yùn)行時將每個實(shí)例存儲到其類列表中,例如 driver1 = new Driver() 將成為 Drivers 一部分 。

一對一 (One-to-One)

> Drivers.filter( d=> d.state == "GA").filter( d => d.vehicle.year > 2010)
// Finds drivers in GA state with car younger than 2010

一對多 (One-to-Many)

> Orders.filter( o => o.price > 100 && o.customer.id == 192)
// Finds orders with bigger than $100 prize of customer with id 192

Other direction

其他方向

> Customers.find( c=> c.id == 192).orders.filter( o=>o.price > 100)

多對多 (Many-to-Many)

Tickets.filter( t => t.passenger.id == 6912 && t.flight.destination == "LA")
// Finds ticket of passenger with id 6912 for destination to FL

Reference: https://nucleoid.org/tutorial/

參考: https : //nucleoid.org/tutorial/

翻譯自: https://medium.com/nucleoid/data-relationships-in-nucleoid-e3837512d264

關(guān)系型數(shù)據(jù)庫的核心單元是

總結(jié)

以上是生活随笔為你收集整理的关系型数据库的核心单元是_核中的数据关系的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。