Download CREATE TABLE Statements for creating new “sqlite” databases

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Relational model wikipedia , lookup

Database model wikipedia , lookup

Transcript
CREATE TABLE Statements for creating new “sqlite” databases
Below are the statements that you need to execute in order to create the
“quotations” and “Schoenberg” databases. We will call the former “example1” and
the latter “example2”.
Before you begin and while you are in the “SQLite Manager” window, do the
following in order to enable Foreign Keys.






Go to DB Settings, change Foreign Keys to ‘On’,
Press ‘Change’
Go to Tools, then ‘Use table for extension data’
Go to Tools, then ‘Open on-connect SQL’
Click on the ‘On connect SQL’ tab – the ‘On-connect SQL statements for THIS
database’ text area is now enabled.
In the field enter: PRAGMA foreign_keys=ON; Press Save.
DB: Example 1 -> the database of quotations, topics and texts
In the SQLite Manager Window, click on “Execute SQL”, and Copy & Paste the
following CREATE TABLE statements (all 3 of them) in the “Enter SQL” text area.
Then, click on “Run SQL”. The “Last Error” field should return “not an error” and on
the left hand side pane, you should see the 3 tables under the tag “Tables”.
 NOTE: do not forget the “;” at the end of each CREATE TABLE statement !
CREATE TABLE "topics" (
"ID" INTEGER PRIMARY KEY
"Topic" TEXT,
"Description" TEXT);
CREATE TABLE "texts" (
"ID" INTEGER PRIMARY KEY
"ShortTitle" TEXT,
"CameronNum" INTEGER,
"Bibliogr" TEXT);
NOT NULL ,
NOT NULL ,
CREATE TABLE "quotations" (
"ID" INTEGER PRIMARY KEY NOT NULL ,
"Declaration" TEXT,
"Source" TEXT ,
"Topic" TEXT,
FOREIGN KEY(Source) REFERENCES texts(ID),
FOREIGN KEY(Topic) REFERENCES topics(ID));
1
Populating a new “sqlite” database
DB: Example 1
Before you begin, you should have the .csv files downloaded on your computer
1.
2.
3.
4.
5.
6.
7.
8.
Click on “Database” -> “Import”
Click “Select File” and find the .csv file you want to import, e.g. “topics.csv”.
Enter the name of the table, e.g. topics.
Click on “Frist row contains column names” (see the .csv file)
Select “Comma (,)” in “Fields separated by”
Leave the rest of the settings unchanged
Click “OK”
Click “OK” in the two following pop-up windows to continue importing.
If you click on the table name (left pane) and the tab “Browse & Search” (middle),
you should be seeing the records that were just imported.
Repeat with all tables for our first example (i.e. “texts” and “quotations”)
THE DATABASE IS READY !!!!!
NOTE: if you use the CREATE TABLE wizard of SQLite Manager, be aware that it
does not give the option to define Foreign Keys. I recommend.
2
DB: Example 2 -> the database of Schoenberg
CREATE TABLE Schoenberg (
"MANUSCRIPT_ID" INTEGER PRIMARY KEY,
"CAT_DATE" DATE,
"SELLER" TEXT,
"SELLER2" TEXT,
"INSTITUTION" TEXT,
"BUYER" TEXT,
"CAT_ID" TEXT,
"CAT_OR_LOT_NUM" INTEGER,
"PRICE" REAL,
"CURRENCY" TEXT,
"SOLD" TEXT,
"SECONDARY_SOURCE" TEXT,
"CURRENT_LOCATION" TEXT,
"AUTHOR_AUTHORITY" TEXT,
"AUTHOR_VARIANT" TEXT,
"TITLE" TEXT,
"LNG" TEXT,
"MAT" CHAR(1),
"PLACE" TEXT,
"MANUSCRIPT_USE" TEXT,
"MANUSCRIPT_DATE" DATE,
"CIRCA" TEXT,
"ARTIST" TEXT,
"SCRIBE" TEXT,
"FOLIOS" INTEGER,
"COL" INTEGER,
"LINES" INTEGER,
"HGT" INTEGER,
"WDT" INTEGER,
"MANUSCRIPT_BINDING" TEXT,
"PROVENANCE" TEXT,
"COMMENTS" TEXT,
"MANUSCRIPT_LINK" TEXT,
"MIN_FL" INTEGER,
"MIN_LG" INTEGER,
"MIN_SM" INTEGER,
"MIN_UN" INTEGER,
"H_INIT" INTEGER,
"D_INIT" INTEGER,
"ENTRY_COMMENTS" TEXT,
"ADDEDON" DATE,
"ADDEDBY" TEXT,
"ISAPPROVED" TEXT,
"ISDELETED" TEXT,
"LAST_MODIFIED" DATE,
"LAST_MODIFIED_BY" TEXT,
"POSSIBLE_DUPS" TEXT
3
)
4