Python Programming for Biology: Bioinformatics and Beyond


SQL creation of the database



Download 7,75 Mb.
Pdf ko'rish
bet307/514
Sana30.12.2021
Hajmi7,75 Mb.
#91066
1   ...   303   304   305   306   307   308   309   310   ...   514
Bog'liq
[Tim J. Stevens, Wayne Boucher] Python Programming

SQL creation of the database

Although we could use Python to create the database and the tables in the database, this is

often done directly in SQL because it is a one-off exercise (except occasional upgrades to



the data model) and there are no particular advantages to using Python in this context.

To create a database in SQLite we just need to refer to it when we do anything, so in

particular  when  we  create  the  tables  it  will  automatically  create  the  database  if  it  is  not

already created. In MySQL you have to create the empty database before you can use it,

and often the system administrator has to do this for you, and set up suitable privileges so

that you can access it. We will assume here that the database has been created.

Given  the  model  discussed  in  the  previous  section,  the  table  creation  in  SQLite  is  as

follows:


CREATE TABLE structure (

id INTEGER,

name TEXT NOT NULL,

pdbId TEXT NOT NULL,

conformation INTEGER NOT NULL,

PRIMARY KEY (id)

);

CREATE TABLE chain (



id INTEGER,

structureId INTEGER NOT NULL,

molType TEXT NOT NULL,

code TEXT NOT NULL,

PRIMARY KEY (id),

FOREIGN KEY (structureId) REFERENCES structure(id)

);

CREATE TABLE residue (



id INTEGER,

chainId INTEGER NOT NULL,

seqId INTEGER NOT NULL,

code TEXT,

PRIMARY KEY (id),

FOREIGN KEY (chainId) REFERENCES chain(id)

);

CREATE TABLE atom (



id INTEGER,

residueId INTEGER NOT NULL,

name TEXT NOT NULL,

x FLOAT NOT NULL, y FLOAT NOT NULL,

z FLOAT NOT NULL,

element TEXT NOT NULL,

PRIMARY KEY (id),

FOREIGN KEY (residueId) REFERENCES residue(id)

);




Download 7,75 Mb.

Do'stlaringiz bilan baham:
1   ...   303   304   305   306   307   308   309   310   ...   514




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish