Home Php C# Sql C C++ Javascript Python Java Go Android Git Linux Asp.net Django .net Node.js Ios Xcode Cocoa Iphone Mysql Tomcat Mongodb Bash Objective-c Scala Visual-studio Apache Elasticsearch Jar Eclipse Jquery Ruby-on-rails Ruby Rubygems Android-studio Spring Lua Sqlite Emacs Ubuntu Perl Docker Swift Amazon-web-services Svn Html Ajax Xml Java-ee Maven Intellij-idea Rvm Macos Unix Css Ipad Postgresql Css3 Json Windows-server Vue.js Typescript Oracle Hibernate Internet-explorer Github Tensorflow Laravel Symfony Redis Html5 Google-app-engine Nginx Firefox Sqlalchemy Lucene Erlang Flask Vim Solr Webview Facebook Zend-framework Virtualenv Nosql Ide Twitter Safari Flutter Bundle Phonegap Centos Sphinx Actionscript Tornado Register | Login | Edit Tags | New Questions | 繁体 | 简体


10 questions online user: 2

7
votes
answers
44 views
+10

热备份与冷备份有何不同?

冷备份和热备份有什么区别?

沙发
+40

热备份

对于热备份关闭不是强制性的,因此在进行热备份时,用户可以使用数据库。

在热备份数据库中不一致。

冷备份

对于冷备份关闭是必要的,因此在此期间用户无法访问数据库。

在冷备份数据库中是一致的。

板凳
+30
  • 当系统没有用户活动时,将执行冷备份。当数据库未运行且没有用户登录时,也称为脱机备份。数据库的所有文件都被复制,并且在复制过程中没有任何更改。
  • 当进行热备份时数据库需要一直运行。这是一个在线备份。复制数据库的所有文件,并且在复制期间可能会对数据库进行更改。
    • 进行热备份的好处是数据库可用于在备份发生时使用,并且可以将数据库恢复到任何时间点。
    • 进行冷备份的好处是通常更容易管理备份和恢复过程。
0
votes
answers
63 views
+10

ORA-02291:完整性約束(H00300581.FK_CLASSES)違反 - 父鍵沒有找到

0

當我做插入給我這個錯誤:ORA-02291:完整性約束(H00300581.FK_CLASSES)違反 - 父鍵沒有找到

ORA-02291: integrity constraint (H00300581.FK_CLASSES) violated - parent key not found

這種錯誤發生的所有鑲入登記表。我需要幫助,請嘗試爲我解決。

它來自表中的外鍵嗎?這可能是因爲我嘗試了一切,但它沒有奏效。

創建表

drop table g3_trainers CASCADE CONSTRAINTS; 
drop table g3_classes CASCADE CONSTRAINTS; 
drop table g3_members CASCADE CONSTRAINTS; 
drop table g3_registration CASCADE CONSTRAINTS; 

CREATE TABLE G3_TRAINERS 
(
TRAINER_ID VARCHAR(6) NOT NULL, 
TRAINER_NAME VARCHAR(50) NOT NULL, 
COUNTRY VARCHAR(25) NOT NULL, 
DOB DATE NOT NULL, 
SPECIALITY VARCHAR(30) NOT NULL, 
DESCRIPTION VARCHAR(500) NOT NULL, 
PRIMARY KEY (TRAINER_ID) 
); 

CREATE TABLE G3_CLASSES 
(
CLASS_NUM VARCHAR(6) NOT NULL, 
TRAINER_ID VARCHAR(6) NOT NULL, 
CLASS_TITLE VARCHAR(50) NOT NULL, 
START_DATE DATE NOT NULL, 
END_DATE DATE NOT NULL, 
COST NUMBER(6) NOT NULL, 
PRIMARY KEY (CLASS_NUM), 
CONSTRAINT fk_TRAINERS FOREIGN KEY(TRAINER_ID) REFERENCES G3_TRAINERS(TRAINER_ID) 
); 

CREATE TABLE G3_MEMBERS 
(
MEMBER_ID VARCHAR(6) NOT NULL, 
MEMBER_NAME VARCHAR(50) NOT NULL, 
MEMBER_AGE NUMBER(2) NOT NULL, 
GENDER VARCHAR(10) NOT NULL, 
PHONE_NUMBER VARCHAR(10) NOT NULL, 
CHECK (regexp_like (PHONE_NUMBER,'^(d{3}-d{3}-?d{4}|d{10})$')), 
CHECK (MEMBER_AGE>=17), 
CHECK(MEMBER_AGE NOT LIKE '%[^a-zA-Z]%'), 
PRIMARY KEY (MEMBER_ID) 
); 

CREATE TABLE G3_REGISTRATION 
(
REGISTRATION_ID VARCHAR(6) NOT NULL, 
MEMBER_ID VARCHAR(6) NOT NULL, 
AMOUNT_TO_PAY NUMBER(6) NOT NULL, 
CLASS_NUM VARCHAR(6) NOT NULL, 
PRIMARY KEY (REGISTRATION_ID), 
CONSTRAINT fk_MEMBERS FOREIGN KEY(MEMBER_ID) REFERENCES G3_MEMBERS(MEMBER_ID), 
CONSTRAINT fk_CLASSES FOREIGN KEY(CLASS_NUM) REFERENCES G3_CLASSES(CLASS_NUM) 
); 

創建序列

CREATE SEQUENCE G3_TRAINER_Seq 
START WITH  10001 
INCREMENT BY 1 
NOCACHE 
NOCYCLE; 

CREATE SEQUENCE G3_MEMBER_Seq 
START WITH  20001 
INCREMENT BY 1 
NOCACHE 
NOCYCLE; 

CREATE SEQUENCE G3_CLASSE_Seq 
START WITH  30001 
INCREMENT BY 1 
NOCACHE 
NOCYCLE; 

CREATE SEQUENCE G3_REGISTRATIONS_Seq 
START WITH  40001 
INCREMENT BY 1 
NOCACHE 
NOCYCLE; 

訓練數據

INSERT INTO G3_TRAINERS (TRAINER_ID, TRAINER_NAME, COUNTRY, DOB, SPECIALITY, DESCRIPTION) 
VALUES (G3_TRAINER_Seq.nextVal, 'Ahmed', 'Eygpt', '2/3/1988', 'Body Building', 'I describe my self as an active guy i workout everyday and thats why i desided to train people to be good as me'); 

INSERT INTO G3_TRAINERS (TRAINER_ID, TRAINER_NAME, COUNTRY, DOB, SPECIALITY, DESCRIPTION) 
VALUES (G3_TRAINER_Seq.nextVal, 'John', 'Canada', '4/6/1987', 'Crossfit', 'I like being healthy and work as much as i can to be fit and to have a great life'); 

INSERT INTO G3_TRAINERS (TRAINER_ID, TRAINER_NAME, COUNTRY, DOB, SPECIALITY, DESCRIPTION) 
VALUES (G3_TRAINER_Seq.nextVal, 'Sara', 'Canada', '9/1/1990', 'Yoga', 'I like interacting with poeple, and to teach them how yoga will be a very good source of flexing and relaxing your body'); 

INSERT INTO G3_TRAINERS (TRAINER_ID, TRAINER_NAME, COUNTRY, DOB, SPECIALITY, DESCRIPTION) 
VALUES (G3_TRAINER_Seq.nextVal, 'Jun', 'China', '12/4/1981', 'Crossfit', 'I describe my self as an daily working guy i like my job because i get to know more about people and i teach many people how to be fit'); 

    INSERT INTO G3_TRAINERS (TRAINER_ID, TRAINER_NAME, COUNTRY, DOB, SPECIALITY, DESCRIPTION) 
VALUES (G3_TRAINER_Seq.nextVal, 'Mike', 'Ohio', '2/22/1981', 'Body Building', 'Being strong and big is what i am aiming for, i like keeping my diet healthy and to train poeple to be healthy and big like me'); 

INSERT INTO G3_TRAINERS (TRAINER_ID, TRAINER_NAME, COUNTRY, DOB, SPECIALITY, DESCRIPTION) 
VALUES (G3_TRAINER_Seq.nextVal, 'Mia', 'Germany', '12/12/1987', 'Yoga', 'I describe myself as a hard working i love my job and i love my members'); 

INSERT INTO G3_TRAINERS (TRAINER_ID, TRAINER_NAME, COUNTRY, DOB, SPECIALITY, DESCRIPTION) 
VALUES (G3_TRAINER_Seq.nextVal, 'Essam', 'UAE', '1/5/1980', 'Body Building', 'I am a hard worker and i like to train my members and i want them to be healthy and strong'); 

類的數據

INSERT INTO G3_CLASSES (CLASS_NUM, TRAINER_ID, CLASS_TITLE, START_DATE, END_DATE, COST) 
VALUES (G3_CLASSE_Seq.nextVal, 10001, 'Weight Lifting Class', '1/12/2017', '1/1/2018', 1150); 

INSERT INTO G3_CLASSES (CLASS_NUM, TRAINER_ID, CLASS_TITLE, START_DATE, END_DATE, COST) 
VALUES (G3_CLASSE_Seq.nextVal, 10001, 'Weight Lifting Class', '1/2/2018', '1/3/2018', 1150); 

INSERT INTO G3_CLASSES (CLASS_NUM, TRAINER_ID, CLASS_TITLE, START_DATE, END_DATE, COST) 
VALUES (G3_CLASSE_Seq.nextVal, 10002, 'Body Weight Class', '2/1/2018', '2/2/2018', 950); 

INSERT INTO G3_CLASSES (CLASS_NUM, TRAINER_ID, CLASS_TITLE, START_DATE, END_DATE, COST) 
VALUES (G3_CLASSE_Seq.nextVal, 10003, 'Yoga Class', '3/2/2018', '3/3/2018', 750); 

INSERT INTO G3_CLASSES (CLASS_NUM, TRAINER_ID, CLASS_TITLE, START_DATE, END_DATE, COST) 
VALUES (G3_CLASSE_Seq.nextVal, 10003, 'Yoga Class', '5/5/2018', '5/6/2018', 750); 

INSERT INTO G3_CLASSES (CLASS_NUM, TRAINER_ID, CLASS_TITLE, START_DATE, END_DATE, COST) 
VALUES (G3_CLASSE_Seq.nextVal, 10004, 'Body Weight Class', '10/2/2018', '10/3/2018', 950); 

INSERT INTO G3_CLASSES (CLASS_NUM, TRAINER_ID, CLASS_TITLE, START_DATE, END_DATE, COST) 
VALUES (G3_CLASSE_Seq.nextVal, 10004, 'Body Weight Class', '10/4/2018', '10/5/2018', 950); 

INSERT INTO G3_CLASSES (CLASS_NUM, TRAINER_ID, CLASS_TITLE, START_DATE, END_DATE, COST) 
VALUES (G3_CLASSE_Seq.nextVal, 10005, 'Weight Lifting Class', '12/20/2017', '1/20/2018', 1150); 

INSERT INTO G3_CLASSES (CLASS_NUM, TRAINER_ID, CLASS_TITLE, START_DATE, END_DATE, COST) 
VALUES (G3_CLASSE_Seq.nextVal, 10005, 'Weight Lifting Class', '2/20/2018', '3/20/2018', 1150); 

INSERT INTO G3_CLASSES (CLASS_NUM, TRAINER_ID, CLASS_TITLE, START_DATE, END_DATE, COST) 
VALUES (G3_CLASSE_Seq.nextVal, 10005, 'Weight Lifting Class', '4/20/2018', '5/20/2018', 1150); 

INSERT INTO G3_CLASSES (CLASS_NUM, TRAINER_ID, CLASS_TITLE, START_DATE, END_DATE, COST) 
VALUES (G3_CLASSE_Seq.nextVal, 10006, 'Yoga Class', '12/28/2017', '1/28/2018', 750); 

INSERT INTO G3_CLASSES (CLASS_NUM, TRAINER_ID, CLASS_TITLE, START_DATE, END_DATE, COST) 
VALUES (G3_CLASSE_Seq.nextVal, 10007, 'Weight Lifting Class', '10/3/2018', '10/4/2018', 1150); 

INSERT INTO G3_CLASSES (CLASS_NUM, TRAINER_ID, CLASS_TITLE, START_DATE, END_DATE, COST) 
VALUES (G3_CLASSE_Seq.nextVal, 10007, 'Weight Lifting Class', '10/5/2018', '10/6/2018', 1150); 

成員數據

INSERT INTO G3_MEMBERS (MEMBER_ID, MEMBER_NAME, MEMBER_AGE, GENDER, PHONE_NUMBER) 
VALUES (G3_MEMBER_Seq.nextVal, 'Mohammed', '21', 'Male', '0502202212'); 

INSERT INTO G3_MEMBERS (MEMBER_ID, MEMBER_NAME, MEMBER_AGE, GENDER, PHONE_NUMBER) 
VALUES (G3_MEMBER_Seq.nextVal, 'Afra', '28', 'Female', '0555544558'); 

INSERT INTO G3_MEMBERS (MEMBER_ID, MEMBER_NAME, MEMBER_AGE, GENDER, PHONE_NUMBER) 
VALUES (G3_MEMBER_Seq.nextVal, 'Essa', '30', 'Male', '0555544558'); 

INSERT INTO G3_MEMBERS (MEMBER_ID, MEMBER_NAME, MEMBER_AGE, GENDER, PHONE_NUMBER) 
VALUES (G3_MEMBER_Seq.nextVal, 'Ahmed', '19', 'Male', '0563020300'); 

INSERT INTO G3_MEMBERS (MEMBER_ID, MEMBER_NAME, MEMBER_AGE, GENDER, PHONE_NUMBER) 
VALUES (G3_MEMBER_Seq.nextVal, 'Alex', '25', 'Female', '0521022932'); 

INSERT INTO G3_MEMBERS (MEMBER_ID, MEMBER_NAME, MEMBER_AGE, GENDER, PHONE_NUMBER) 
VALUES (G3_MEMBER_Seq.nextVal, 'Abdulla', '24', 'Male', '0504493393'); 

INSERT INTO G3_MEMBERS (MEMBER_ID, MEMBER_NAME, MEMBER_AGE, GENDER, PHONE_NUMBER) 
VALUES (G3_MEMBER_Seq.nextVal, 'Abdulrahman', '20', 'Male', '0502292290'); 

INSERT INTO G3_MEMBERS (MEMBER_ID, MEMBER_NAME, MEMBER_AGE, GENDER, PHONE_NUMBER) 
VALUES (G3_MEMBER_Seq.nextVal, 'Olivia', '21', 'Female', '0561020200'); 

INSERT INTO G3_MEMBERS (MEMBER_ID, MEMBER_NAME, MEMBER_AGE, GENDER, PHONE_NUMBER) 
VALUES (G3_MEMBER_Seq.nextVal, 'Omar', '30', 'Male', '0502503323'); 

INSERT INTO G3_MEMBERS (MEMBER_ID, MEMBER_NAME, MEMBER_AGE, GENDER, PHONE_NUMBER) 
VALUES (G3_MEMBER_Seq.nextVal, 'Nasser', '29', 'Male', '0504334439'); 

INSERT INTO G3_MEMBERS (MEMBER_ID, MEMBER_NAME, MEMBER_AGE, GENDER, PHONE_NUMBER) 
VALUES (G3_MEMBER_Seq.nextVal, 'Sophia', '22', 'Female', '0561616316'); 

INSERT INTO G3_MEMBERS (MEMBER_ID, MEMBER_NAME, MEMBER_AGE, GENDER, PHONE_NUMBER) 
VALUES (G3_MEMBER_Seq.nextVal, 'Nadia', '21', 'Female', '0507797786'); 

註冊數據

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20001, 1150, 30001); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20001, 750, 30004); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20002, 750, 30004); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20002, 950, 30006); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20003, 1150, 30001); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20003, 1150, 300010); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20004, 950, 30006); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20004, 1150, 30010); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20005, 1150, 30007); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20005, 750, 30011); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20006, 1150, 30013); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20006, 1150, 30012); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20007, 1150, 30009); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20007, 750, 30011); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20008, 1150, 30008); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20008, 750, 30011); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20009, 1150, 30013); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20009, 750, 30005); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20010, 1150, 30013); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20010, 1150, 30012); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20010, 950, 30007); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20011, 1150, 30013); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20011, 750, 30005); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20012, 750, 30004); 

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) 
VALUES (G3_REGISTRATIONS_Seq.nextVal, 20012, 1150, 30009); 
+0

您的腳本有太多錯誤。有幾個地方丟失了逗號。您在插入語句中使用的序列名稱中存在拼寫錯誤。首先解決這些問題。 –

+0

@Kaushik Nayak我修復了一些小問題,我如何添加代碼? –

+0

@Kaushik Nayak我編輯它看看它 –

沙发
0
0

commas缺少的大多數語句,如:

between 'Eygpt' & '12/3/1988' in :

INSERT INTO G3_TRAINERS (TRAINER_ID, TRAINER_NAME, COUNTRY, DOB, 
SPECIALITY, DESCRIPTION) VALUES (G3_TRAINERS_Seq.nextVal, 'Ahmed', 
'Eygpt' '12/3/1988', 'Body Building', 'I describe my self as an active 
guy i workout everyday and thats why i desided to train people to be 
good as me'); 

OR

between 'Weight Lifting Class' & '1/12/2017'

INSERT INTO G3_CLASSES (CLASS_NUM, TRAINER_ID, CLASS_TITLE, START_DATE, END_DATE, COST) 
VALUES (G3_CLASSES_Seq.nextVal, 10001, 'Weight Lifting Class' '1/12/2017', '1/1/2018', 1150); 

你有CONSTRAINT fk_CLASSES FOREIGN KEY(CLASS_NUM) REFERENCES G3_CLASSES(CLASS_NUM)爲約束

G3_CLASSES_Seq序列填充g3_classes表的class_num列,應該是方便,fk_CLASSES FOREIGN KEY,但你有另一個序列G3_CLASSE_Seq開始30000。順便說一句,現在看來,這應該與30001

i.e. Pay attention that G3_CLASSE_Seq and G3_CLASSES_Seq are different.

的方式啓動,刪除空格在column names之間create sentences類似以下內容:

爲例,其轉換

CREATE TABLE G3_TRAINERS 
(

TRAINER_ID VARCHAR(6) NOT NULL, 
TRAINER_NAME VARCHAR(50) NOT NULL, 
COUNTRY VARCHAR(25) NOT NULL, 
DOB DATE NOT NULL, 
SPECIALITY VARCHAR(30) NOT NULL, 
DESCRIPTION VARCHAR(500) NOT NULL, 

PRIMARY KEY (TRAINER_ID) 

); 

對此:

CREATE TABLE G3_TRAINERS 
(
TRAINER_ID VARCHAR(6) NOT NULL, 
TRAINER_NAME VARCHAR(50) NOT NULL, 
COUNTRY VARCHAR(25) NOT NULL, 
DOB DATE NOT NULL, 
SPECIALITY VARCHAR(30) NOT NULL, 
DESCRIPTION VARCHAR(500) NOT NULL, 
PRIMARY KEY (TRAINER_ID) 
); 

An d在以下語句中存在另一個問題(300010

INSERT INTO G3_REGISTRATION (REGISTRATION_ID, MEMBER_ID, AMOUNT_TO_PAY, CLASS_NUM) VALUES (G3_REGISTRATIONS_Seq.nextVal, 20003, 1150, 300010);

+0

非常感謝,解決了我的其他問題之一,但我發佈了主要問題 –

+0

@abdulrahmanarab請看我最後編輯的外鍵和序列。 –

+0

@abdulrahmanarab我認爲,問題不是使用'G3_CLASSE_Seq'(你應該使用這個,從30001開始)。您正在使用'G3_CLASSES_Seq'。 –

0
votes
answers
49 views
+10

火力地堡和recyclerView

0

嗨,我是在火力和Android工作室新和我有一個問題火力地堡和recyclerView

我想這個數據庫的數據陣列存儲在數組中,並在下一次使用,使回收者視圖

enter image description here

然後在主要活動我寫了這個:

enter image description here

如果我只運行的應用程序這顯示:

enter image description here

但是,如果我做同樣的但不是火力我使用的String []與數據我想說明它的工作原理,但我不知道爲什麼與火力點我可以」噸。

,如果我這個改變引用:

reference = database.getReference(FirebaseReferences.POKEMONS_REFERENCES); 
     reference.child(FirebaseReferences.APP_REFERENCES).addValueEventListener(new ValueEventListener() { 

當我運行的應用程序,它會自動關閉,我不知道該怎麼辦。

你能告訴我我做錯了什麼嗎?

預先感謝您。

這裏是logcat的 所有的https://github.com/adcasna/SearchViewPrueba2/wiki

+0

顯示您的logcat的。 – Deepa

+0

Ater for循環嘗試調用adapter.notifyDataSetChanged(); –

+0

你應該添加你的代碼而不是添加圖片的問題。 –

沙发
0
0

Fisrts,請注意火力地堡文檔建議不要使用數組。談到Firebase時,使用數組是一種反模式。 Firebase建議不要使用陣列的原因之一是它使安全規則無法寫入。如果你仍然想使用這種結構,爲獲得這些名稱,並將其存儲在一個ArrayList,請使用如下代碼:

DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference(); 
DatabaseReference appRef = rootRef.child("pokemons").child("app"); 
ValueEventListener eventListener = new ValueEventListener() { 
    @Override 
    public void onDataChange(DataSnapshot dataSnapshot) { 
     List<String> list = new ArrayList<>(); 
     for(DataSnapshot ds : dataSnapshot.getChildren()) { 
      String c_name = ds.child("c_name").getValue(String.class); 
      list.add(c_name); 
      Log.d("TAG", c_name); 
     } 
     Log.d("TAG", list); 
    } 

    @Override 
    public void onCancelled(DatabaseError databaseError) {} 
}; 
appRef.addListenerForSingleValueEvent(eventListener); 
0
votes
answers
62 views
+10

平面文件作爲輸入 - MySQL最佳實踐

0

我每天都會收到一個平面文件(CSV),其內容會被導入到我的數據庫中(而不是通過Web表單,POS等的數據輸入)。有一個記錄中有40個字段,我有600,000個獨特的記錄。平面文件作爲輸入 - MySQL最佳實踐

到目前爲止,我還沒有看到有必要將這個關係數據庫作爲關係數據庫,儘管肯定會有一些規範化使它更有效;重複的產品,商店,客戶,經銷商等

如果我從一開始就開始並以某種方式逐步輸入數據,我會知道如何做到這一切(我經歷的每一個資源都涵蓋了但是當你有大量的數據並且需要使它成爲關係時,沒有一種方法可以覆蓋它)。並且隨着CVS每天到來,我不太清楚在數據庫建立後如何導入數據。如果我將這40個字段分成5個表格,那麼我必須以同樣的方式拆分每日文件並一次導入它們一個嗎?外鍵會以這種方式更新嗎?

如果有人能把我推向正確的方向,我會去做更多的自己挖掘。

如果您遇到同一個項目,您將如何創建這樣的數據庫並執行每日更新?

謝謝!

沙发
0
0

獨立於您現在所擁有的(CSV結構和數據)創建數據庫結構。例如。組織你的桌子以適應你未來的需求,思考和定義好他們之間的關係,運用適當的指標。

作爲第二步 - 在我看來是不可避免的,用你自己的編程語言編寫一個小程序。它應該能夠

  • 主要是讀從(CSV)文件中的記錄/行,
  • 驗證/消毒獲取的數據
  • 進口/根據需要保存在數據庫中對應表中的數據。 「根據需要」,我的意思是說,隨着時間的推移,可能會出現許多因素,這些因素可能會意外地影響您的第一個數據庫結構決策。例如,需要一些時態表。另外,您應該從觸發器和存儲過程給您帶來的好處中受益。
  • 正確處理導入過程中引發的錯誤和異常。例如,由於最終的「重複密鑰」問題 - 因爲文件中的數據可能容易出錯,所以某些記錄無法在某一天導入。這並不意味着進口應該打破。閱讀一條記錄,嘗試保存它。如果出現問題,處理它(複製另一個文件中的行,或將它保存在一個特殊的表中,以供以後編輯/修訂並重新導入),並讓程序按照其過程中的下一個記錄。
  • 正確記錄所有(主要)操作並維護讀取計數器和有問題的記錄。
  • 自動將每個日常文件 - 導入後 - 複製到備份目錄中,直到它不再需要爲止。
  • 最終會通過電子郵件向您發出有關操作狀態的信號。

第三步是找到一個自動化整個循環的解決方案。例如,要找到一個任務/ cron-jobs管理器來每天啓動一次或每天兩次的程序,而無需手動進行此操作。

關於根據您的數據庫結構將文件拆分爲不同的文件:這不是必要的,例如,這將是一個多餘的步驟,因爲您的程序應該設法讀取文件並相應地處理數據導入。

至於程序的類型:它應該是一個Web解決方案,以便您可以隨時訪問和修改它。

祝你好運。

+0

偉大的輪廓和我正在尋找的方向。謝謝aendeerei! –

0
votes
answers
78 views
+10

未處理的異常錯誤 - 用戶登錄失敗

0

這裏有一個奇怪的錯誤。在我們的ASP.NET 4.6應用中,使用實體框架6.2,當訪問SQL Azure數據庫時,我們得到「用戶登錄失敗」。我很確定錯誤的原因是在Azure中切換層。我沒有得到的是爲什麼沒有發現錯誤。我們所有的SQL操作都在try ... catch塊內。錯誤從塊中消失,並在應用程序崩潰之前被Globals.asax捕獲。 我們有未處理的異常錯誤 - 用戶登錄失敗

SetExecutionStrategy("System.Data.SqlClient", Function() New SqlServer.SqlAzureExecutionStrategy(10, TimeSpan.FromSeconds(7))) 

其中,按照我的理解,將重試任何SQL執行10次,至少70秒內從第一個錯誤。根據微軟技術支持,這不是因爲它尚未與SQL Azure建立連接而參與其中。 ConnectRetryCount和連接字符串中的時間間隔不適用,因爲它正在與服務器通話。服務器只是說,「我知道你在那裏,但我不會讓你進去!」 根據MS Tech的支持,解決這個問題的唯一方法就是圍繞我們所有的SQL命令嘗試...... catch塊......我們這樣做!它只是通過和崩潰的應用程序!

我不能在globals.asax中重試,因爲那時它已經崩潰了。 根據MS,沒有辦法在上下文中捕獲錯誤並從那裏重試。那麼,解決方案是什麼?除了「只是讓應用崩潰並讓他們刷新頁面」之外,還必須有一些答案!

當頁面刷新幾秒後,一切正常。沒有錯誤,沒有問題。

的代碼引發錯誤的線路之一的實例:

MapTo = ctx.BrowserMaps.FirstOrDefault(Function(x) code.Contains(x.NameOrUserAgent)) 

這真的很簡單。這個只是碰巧遇到了很多,因爲這個代碼塊被頻繁調用。實際的SQL請求是不相關的,因爲不管使用哪條線,EF內的連接都會失敗。

沙发
0
2

服務器登錄將斷開連接,同時向上/向下擴展到新層,並且事務回滾。但是,包含的數據庫登錄在擴展過程中保持連接狀態,因此建議通過服務器登錄進行登錄。

嘗試並捕獲可能無法解決問題,因爲您可能正在捕獲錯誤#0,並且Azure SQL數據庫中的很多錯誤落在該錯誤0類別上。

只是一個評論,縮放後的性能可能在縮放後很差,幾分鐘後會提高。查詢計劃也可能會改變。

+0

這或多或少是答案。在我們的例子中,在模型的構造函數中放置一個try.catch允許我們設置一些重試邏輯。我們正在調查數據庫登錄,謝謝。 –

0
votes
answers
39 views
+10

自動添加額外的firebase數據庫字段?

0

我有一本書類作爲自動添加額外的firebase數據庫字段?

public class Books { 

    public String bookName; 
    public String author; 
    public String copies; 

    public Books() { 
     // Default constructor required for calls to DataSnapshot.getValue(User.class) 
    } 

    public Books(String name, String author, String copies) { 
     this.bookName = name; 
     this.author = author; 
     this.copies = copies; 
    } 

    public String getBookName() { 
     return bookName; 
    } 

    public String getAuthorName() { 
     return author; 
    } 


    public String getCopies() { 
     return copies; 
    } 

} 

而且我增添火力實時雲數據庫作爲

mDatabase = FirebaseDatabase.getInstance("https://cmpe-2b339.firebaseio.com").getReference(); 

Books book = new Books(bookName,author,copies); 
        mDatabase.push().setValue(book); 

但是在火力檢測控制檯,其作爲

{ 
    "-KzAt3eHDBtD7gFvLIbn" : { 
    "author" : "J", 
    "authorName" : "J", 
    "bookName" : "Hi", 
    "copies" : "5" 
    } 
} 

有未來添加作者字段,我不明白

沙发
0
1

你有ap名爲「author」的ublic變量和名爲「getAuthorName」的公共getter。 Firebase反射正在使用兩者來在數據庫中創建數據。修復:使你的變量保持私密並保持getters,然後添加setter。

+0

這是什麼意思更換類。它解決了這個問題? – raxx

+0

反射是一個Java屬性,您可以在不知道方法或變量的名稱的情況下訪問另一個類。 Firebase使用反射來檢查報告正在上傳。這就是爲什麼你應該爲此使用標準的POJO java類。其他答案指向相同的方向。 – cutiko

板凳
0
1

與此

public class Books { 
private String bookName; 
private String author; 
private String copies; 

public Books() { 

} 

public Books(String bookName, String author, String copies) { 
    this.bookName = bookName; 
    this.author = author; 
    this.copies = copies; 
} 

public String getBookName() { 
    return bookName; 
} 

public void setBookName(String bookName) { 
    this.bookName = bookName; 
} 

public String getAuthor() { 
    return author; 
} 

public void setAuthor(String author) { 
    this.author = author; 
} 

public String getCopies() { 
    return copies; 
} 

public void setCopies(String copies) { 
    this.copies = copies; 
} 
} 
+0

你能解釋爲什麼嗎?它的工作 – raxx

+0

你的問題解決了嗎? –

0
votes
answers
56 views
+10

無法將數據發送到火力

0

試圖發送一些數據火力卻深藏不露無法將數據發送到火力

public class MainActivity extends AppCompatActivity { 

    private static final String TAG = MainActivity.class.getSimpleName(); 
    private TextView txtDetails; 
    private EditText name,age,gender,mobile,address,blood,bp,date; 
    private Button submit; 
    private FirebaseDatabase firebaseInstance; 
    private DatabaseReference firebaseDatabase; 
    private String patientId; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     txtDetails = findViewById(R.id.txtheading); 
     name = findViewById(R.id.edname); 
     age = findViewById(R.id.edage); 
     gender = findViewById(R.id.edgender); 
     mobile = findViewById(R.id.edmobile); 
     blood = findViewById(R.id.edblood); 
     bp = findViewById(R.id.edbp); 
     date = findViewById(R.id.eddate); 
     submit = findViewById(R.id.btnsubmit); 

     firebaseInstance = FirebaseDatabase.getInstance(); 
     firebaseDatabase = firebaseInstance.getReference("Doctor"); 

     submit.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View view) { 

       String Name = name.getText().toString(); 
       String Age = age.getText().toString(); 
       String Gender = gender.getText().toString(); 
       String Mobile = mobile.getText().toString(); 
       String Blood = blood.getText().toString(); 
       String BP = bp.getText().toString(); 
       String Date = date.getText().toString(); 

      if(TextUtils.isEmpty(patientId)) { 
       createPatient(Name,Age,Gender,Mobile,Blood,BP,Date); 
      } 
      else { 

       updatePatient(Name,Age,Gender,Mobile,Blood,BP,Date); 
      } 
      } 
     }); 

    } 

    private void updatePatient(String name, String age, String gender, 
           String mobile, String blood, 
           String bp, String date) { 



    } 
    private void createPatient(String name, String age, String gender, 
           String mobile, String blood, String bp, String date) { 

     if(TextUtils.isEmpty(patientId)) { 

      patientId = firebaseDatabase.push().getKey(); 
     } 

     Patient patient = new Patient(name,age,gender,mobile,blood,bp,date); 
     firebaseDatabase.child(patientId).setValue(patient); 
     addUserChangeListener(); 

    } 

    private void addUserChangeListener() { 

      firebaseDatabase.child(patientId).addValueEventListener(new ValueEventListener() { 
       @Override 
       public void onDataChange(DataSnapshot dataSnapshot) { 

        Patient patient = dataSnapshot.getValue(Patient.class); 
        if(patient==null) { 


         Log.e(TAG, "User data is changed !"); 
         return; 
        } 

        Log.e(TAG, "User data is changed!" + patient.Names + ", " + patient.Address +", "+patient.Age + 
        "," +patient.Blood +"," +patient.BP+ "," +patient.Gender + 
        "," +patient.Mobile + "," +patient.Date); 



       } 

       @Override 
       public void onCancelled(DatabaseError databaseError) { 
        Log.e(TAG, "Failed to read user", databaseError.toException()); 
       } 
      }); 

    } 


    } 

這裏是我的Patient類:

public class Patient { 

    public String Names; 
    public String Age; 
    public String Gender; 
    public String Mobile; 
    public String Address; 
    public String Blood; 
    public String BP; 
    public String Date; 


    public Patient(String name, String age, String gender, String mobile, String blood, String bp, String date) { 
    } 

    public Patient(String names, String age, String gender, 
        String mobile, String address, String blood, 
        String BP, String date) { 
     Names = names; 
     Age = age; 
     Gender = gender; 
     Mobile = mobile; 
     Address = address; 
     Blood = blood; 
     this.BP = BP; 
     Date = date; 
    } 

    public Patient(String name, String age, String gender, String mobile, String blood, String bp, String date) { 
    } 
} 
+0

可以顯示Patient類 –

+0

@ svi.data我編輯,請 –

沙发
0
0

首先刪除此:

 if(TextUtils.isEmpty(patientId)) { 

     } 

由此:

 createPatient(Name,Age,Gender,Mobile,Blood,BP,Date); 

這:

 patientId = firebaseDatabase.push().getKey(); 

然後使用地圖,而不是類的存儲信息。

所以刪除此

Patient patient = new Patient(name,age,gender,mobile,blood,bp,date); 

和createPatient方法看起來像這樣

private void createPatient(String name, String age, String gender, 
          String mobile, String blood, String bp, String date) { 



    //create a push id like that 
    patientId = firebaseDatabase.push().getKey(); 

    //make a map called patientmap 

    Map patientmap=new HashMap(); 

    //add your values like this to the map 

     patientmap.put("Name",name); 
     patientmap.put("Age",age); 
     patientmap.put("Gender",gender); 
     patientmap.put("Mobile",mobile); 
     patientmap.put("Blood",blood); 
     patientmap.put("BP",bp); 
     patientmap.put("Date",date); 

    firebaseDatabase.child(patientId).setValue(patientmap); 
    addUserChangeListener(); 

} 
+0

請檢查新的答案,希望能幫助到你。 –

+0

謝謝,我會嘗試讓你知道 –

0
votes
answers
56 views
+10

無法使用FirebaseRecyclerAdapter將Firebase JSON轉換爲Java對象

0

我有兩個活動,一個用於創建評估對象,另一個用於列出Firebase中的評估對象,但是我遇到了一個問題:POJO能夠序列化爲JSON很好,但FirebaseRecyclerAdapter似乎無法將JSON數據返回給對象類型。無法使用FirebaseRecyclerAdapter將Firebase JSON轉換爲Java對象

這是我的目標文件:

@IgnoreExtraProperties 
public class Assessment { 

private String company; 
private String industry; 
private String location; 
private String product; 
private String ownerId; 
private String ownerName; 
private boolean isDraft; 
private boolean isQuickWalk; 
private Map<String, Category> categories; 



public Assessment() { 
    // Default constructor required for calls to DataSnapshot.getValue() 
} 

public Assessment(String companyName, String industryName, String locationName, 
        String productName, String ownerId, String ownerName, boolean isDraft, boolean isQuickWalk, Map<String, Category> categories) { 
    this.company = companyName; 
    this.industry = industryName; 
    this.location = locationName; 
    this.product = productName; 
    this.ownerId = ownerId; 
    this.ownerName = ownerName; 
    this.isDraft = isDraft; 
    this.isQuickWalk = isQuickWalk; 
    this.categories = categories; 
} 

public String getCompanyName() { 
    return company; 
} 

public String getIndustryName() { 
    return industry; 
} 

public String getLocationName() { 
    return location; 
} 

public String getProductName() { 
    return product; 
} 

public String getOwnerName() { 
    return ownerName; 
} 

public boolean getIsDraft() { 
    return isDraft; 
} 

public boolean getIsQuickWalk() { 
    return isQuickWalk; 
} 

在此基礎上,我用這個代碼寫入到火力地堡,這一切工作正常:

String key = mDatabaseRef.child(FIREBASE_ASSESSMENTS).push().getKey(); 
Assessment assessment = new Assessment(editCompanyText, editLocationText, 
         editIndustryText, editProductText, uid, 
currentUser.getEmail(), isDraft, isQuickWalk, null); 

Map<String, Object> childUpdates = new HashMap<>(); 
       childUpdates.put("/" + FIREBASE_ASSESSMENTS + "/" + key, 
assessment); 
mDatabaseRef.updateChildren(childUpdates); 

然而,當我試着從閱讀數據庫我相信這是問題所在:

FirebaseRecyclerAdapter<Assessment, ViewDraftsViewHolder> adapter; 
    mRecyclerView = (RecyclerView) findViewById(R.id.draft_recycler_view); 
    mRecyclerView.setHasFixedSize(true); 
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); 

    Query query = mEvalRef; 
    FirebaseRecyclerOptions<Assessment> options = new FirebaseRecyclerOptions.Builder<Assessment>() 
      .setQuery(query, Assessment.class) 
      .build(); 

    adapter = new FirebaseRecyclerAdapter<Assessment, ViewDraftsViewHolder>(options) { 
     @Override 
     protected void onBindViewHolder(ViewDraftsViewHolder holder, int position, Assessment model) { 
      if(model.getIsDraft()) { 
       holder.companyName.setText(model.getCompanyName()); 
       holder.industryName.setText(model.getIndustryName()); 
       holder.locationName.setText(model.getLocationName()); 
       holder.productName.setText(model.getProductName()); 
       holder.ownerName.setText(model.getOwnerName()); 

       if(model.getIsQuickWalk()) { 
        holder.isQuickWalk.setText("Quick Walkthrough"); 
       } else { 
        holder.isQuickWalk.setText("Full Questionnaire"); 
       } 
      } 

     } 

     @Override 
     public ViewDraftsViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 
      View view = LayoutInflater.from(parent.getContext()) 
        .inflate(R.layout.completed_and_drafts_list_item, parent, false); 
      return new ViewDraftsViewHolder(view); 
     } 
    }; 

    mRecyclerView.setAdapter(adapter); 

    private static class ViewDraftsViewHolder extends RecyclerView.ViewHolder { 
    TextView companyName; 
    TextView industryName; 
    TextView locationName; 
    TextView productName; 
    TextView ownerName; 
    TextView isQuickWalk; 

    public ViewDraftsViewHolder(View itemView) { 
     super(itemView); 

     companyName = (TextView) itemView.findViewById(R.id.companyView); 
     industryName = (TextView) itemView.findViewById(R.id.industryView); 
     locationName = (TextView) itemView.findViewById(R.id.locationView); 
     productName = (TextView) itemView.findViewById(R.id.productView); 
     ownerName = (TextView) itemView.findViewById(R.id.ownerName); 
     isQuickWalk = (TextView) itemView.findViewById(R.id.isQuickWalkView); 
    } 
} 

我不確定我要去哪裏g FirebaseRecyclerAdapter無法將數據轉換回Assessment對象。我沒有正確設置對象嗎?我沒有正確設置RecyclerAdapter嗎?這是數據的外觀在火力地堡

"-KzB39l1KH6MyEsgr6Ke" : { 
    "companyName" : "testing ", 
    "industryName" : "at", 
    "isDraft" : true, 
    "isQuickWalk" : true, 
    "locationName" : "five fifteen", 
    "ownerName" : "[email protected]", 
    "productName" : "please ignore" 
}, 

任何幫助,您可以給我將是極好的,我一直在包裹我的頭圍繞這幾天掙扎。謝謝!!

沙发
0
1

在這一行:

Query query = mEvalRef; 

我認爲mEvalRef是數據庫基準,可以顯示它,因爲它不清楚如何從數據庫中查詢數據。

只需添加(mEvalRef),以便找到問題。

編輯

在你的(評估)班,我注意到,有是變量沒有setter方法,添加setter方法類中的每個變量,看看是否有所幫助。

EDIT 2

在你的代碼,你試圖讀出值。

刪除這個

FirebaseRecyclerOptions<Assessment> options = new FirebaseRecyclerOptions.Builder<Assessment>() 
     .setQuery(query, Assessment.class) 
     .build(); 

並且在該線或適配器初始化的一部分:

adapter = new FirebaseRecyclerAdapter<Assessment, ViewDraftsViewHolder>(options) 

除去(選項)參數和改變的代碼,以此上面的行:

 adapter = new FirebaseRecyclerAdapter<Assessment, ViewDraftsViewHolder>(Assessment.class, R.layout.completed_and_drafts_list_item, ViewDraftsViewHolder.class, query) 

下一個刪除該代碼:

 @Override 
    public ViewDraftsViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 
     View view = LayoutInflater.from(parent.getContext()) 
       .inflate(R.layout.completed_and_drafts_list_item, parent, false); 
     return new ViewDraftsViewHolder(view); 
    } 

終於改變(私人)至(公)在此:

private static class ViewDraftsViewHolder extends RecyclerView.ViewHolder { 

,不要忘記保持setter方法變量,評估類,使變量公衆,我告訴你。

編輯3

現在忘掉EDIT 2並重新輸入你的代碼中原來所採取的方式,只是這樣做,你配置後的一切:

在您初始化適配的方法,添加在此之前:

mRecyclerView.setAdapter(adapter); 

這樣的:

adapter.startListening(); 
+0

'mReference = FirebaseDatabase.getInstance()。getReference(); mEvalRef = mReference.child(FIREBASE_ASSESSMENTS);'是我如何使用它,其中'FIREBASE_ASSESSMENTS'是在我火力 結構中的條目常數是這樣的: 應用 | ___評估 | | ___ {子鍵} | ___用戶 | ___ etc – Tadhg

+0

檢查編輯,看看是否有幫助 –

+0

添加setter沒有改變任何我害怕。在技??術上,這些變量是在呼叫新評估時設定的,即「評估=新評估(a,b,c,d等)」; – Tadhg

0
votes
answers
65 views
+10

我如何跟蹤一個人去某個地方的時間?

0

我正在爲健身房創建數據庫來跟蹤成員信息。我希望能夠跟蹤人們出行的時間,以便您能夠看到最繁忙的時間。我不知道如何去做這件事。我是否需要爲會員何時出發的信息製作新表格或將其添加到會員表格或健身房表格中?我如何跟蹤一個人去某個地方的時間?

+0

歡迎來到StackOverflow!我們需要更多的背景資料才能在這裏爲您提供幫助。例如,我們需要了解表格的當前結構。要知道某些信息是否應該進入成員表或gyms表,我們需要知道這些表包含哪些數據。 – LauraS

沙发
0
0

我會添加到不同的表。您可以使用user_id創建一個與user表中的用戶ID相同的新表。如果這是一個重點,那麼將訪問與用戶關聯起來會非常容易。

板凳
0
0

有以下的列

  • 創建一個訪問表visitId
  • MEMBERID
  • gymId
  • entryTime
  • EXITTIME

的GymId列可能無法在需要你成員與健身房相關,但取決於您的要求

地板
0
0

用「域」模型來思考。從你的問題看來,你已經有會員和健身房模型。

我建議引入考勤模式。

Attendance 
    - UserId 
    - CheckInDateTime 

這將轉化爲一個名爲「出勤」的新數據庫表與相應的列。

爲了看什麼時候是最忙碌的時間 - 我會在出席表上執行一個「select count」語句,並在check_in_date列中執行「group by」(截斷時間部分)。

關於持續日期時間值的說明。建議將日期時間值存儲在UTC時區中。然後,您可以讓您的應用程序在查看數據時相應地轉換時區。

0
votes
answers
63 views
+10

是否在CA-central-1區域中提供AWS Aurora for PostgreSQL?

1

我試圖通過亞馬遜的網絡界面在ca-central-1(加拿大)設置一個Aurora PostgreSQL數據庫,但儀表板只給我選擇Aurora MySQL的選項。是否在CA-central-1區域中提供AWS Aurora for PostgreSQL?

Aurora PostgreSQL兼容實例在加拿大還沒有提供,或者這是亞馬遜網絡界面中的錯誤?

沙发
0
2

Aurora Postgres SQL兼容性實例在加拿大尚未提供。您可以參考pricing page來查找各個數據庫引擎的可用性。