0% found this document useful (0 votes)
77 views5 pages

SQL Bookstore V1

The document contains SQL statements to create tables for an online bookstore database including tables for users, writers, book types, genres, translators, languages, book PDFs, printed books, book sales and their relationships. Primary and foreign keys are defined to link the tables together.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views5 pages

SQL Bookstore V1

The document contains SQL statements to create tables for an online bookstore database including tables for users, writers, book types, genres, translators, languages, book PDFs, printed books, book sales and their relationships. Primary and foreign keys are defined to link the tables together.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

create table users(

user_id number(30,0) constraint id_u primary key,


name nvarchar2(20)not null,
password nvarchar2(20)not null)

create table writers(


writer_id number(30,0),
writer_name nvarchar2(20)not null,
contact number(30,0)not null,
constraint id_w primary key(writer_id))

create table book_type(


type_id number(30,0),
type nvarchar2(20)not null,
constraint id_t primary key(type_id))

create table genre_type(


genre_id number(30,0),
genre nvarchar2(20)not null,
constraint id_g primary key(genre_id))

create table translator(


translator_id number(30,0),
translator_name nvarchar2(20)not null,
contact number(30,0)not null,
constraint id_tr primary key(translator_id))

create table all_language(


language_id number(30,0),
language nvarchar2(20)not null,
constraint id_lang primary key(language_id))

create table pdf(


pdf_id number(30,0),
book_pdf blob ,
pdf_book_part number(2,0),
constraint id_pdf primary key(pdf_id));

create table printed(


print_id number(30) ,
print_date date,
print_price number(6,3),
Print_count number(3),
constraint id_printed primary key(print_id)
)

create table books(


book_id number(30,0) constraint id_bok_pk primary key,
no_page number(30,0)not null,
print_year number(30,0)not null,
edition number(30,0)not null,
book_title nvarchar2(20)not null,
book_type_id number(30,0) ,
genre_id number(30,0),
written_in_language_id number(30,0),
book_cover blob,
book_pdf_id number(30,0) ,
constraint book_pdf_fk foreign key (book_pdf_id)references pdf(pdf_id),
constraint book_type_fk foreign key (book_type_id)references book_type(type_id),
constraint gen_id_fk foreign key (genre_id)references genre_type(genre_id),
constraint lang_id_fk foreign key(written_in_language_id)references
all_language(language_id),
writer_id number(30,0) constraint writer references writers(writer_id))

create table is_a_translated_books(


book_id number(30,0) constraint id_book_fk references books(book_id),
translated_to_lang number(30,0) constraint translated_to_lang references
all_language(language_id),
translator_id number(30,0),
constraint pk_book_id_translated primary key(book_id)

create table translated_book(


translator_id number(30,0),
language_id number(30,0),
translated_bookID number(30,0),
constraint tr_id foreign key (translator_id)references translator(translator_id),
constraint tr_book_id foreign key (translated_bookID)references books(book_id),
constraint lang_id foreign key (language_id)references all_language(language_id),
constraint trans_books_pk primary key (translated_bookID,translator_id))

create table printed_books(


printed_book number(30) constraint printed_book_id references books(book_id) ,
printing_id number(30) constraint printed_id references printed(print_id)
constraint printed_book_pk primary key
)

create table sales(


sale_id number(30) ,
book_sale_price number(6,3),
sale_date date,
sale_discount number(3,0),
sale_count number(3),
constraint id_sale primary key(sale_id)
)

create table saled_books(


saled_book number(30) constraint saled_book_id references sales(sale_id)
constraint saled_book_id_pk primary key ,
print_id number(30) constraint print_id references printed_books(printing_id)
)
create table users(
user_id number(30,0) constraint id_u primary key,
name nvarchar2(20)not null,
password nvarchar2(20)not null)

create table writers(


writer_id number(30,0),
writer_name nvarchar2(20)not null,
contact number(30,0)not null,
constraint id_w primary key(writer_id))

create table book_type(


type_id number(30,0),
type nvarchar2(20)not null,
constraint id_t primary key(type_id))

create table genre_type(


genre_id number(30,0),
genre nvarchar2(20)not null,
constraint id_g primary key(genre_id))

create table translator(


translator_id number(30,0),
translator_name nvarchar2(20)not null,
contact number(30,0)not null,
constraint id_tr primary key(translator_id))

create table all_language(


language_id number(30,0),
language nvarchar2(20)not null,
constraint id_lang primary key(language_id))

create table pdf(


pdf_id number(30,0),
book_pdf blob ,
pdf_book_part number(2,0),
constraint id_pdf primary key(pdf_id));
create table printed(
print_id number(30) ,
print_date date,
print_price number(6,3),
Print_count number(3),
constraint id_printed primary key(print_id)
)

create table books(


book_id number(30,0) constraint id_bok_pk primary key,
no_page number(30,0)not null,
print_year number(30,0)not null,
edition number(30,0)not null,
book_title nvarchar2(20)not null,
book_type_id number(30,0) ,
genre_id number(30,0),
written_in_language_id number(30,0),
book_pdf_id number(30,0) ,
constraint book_pdf_fk foreign key (book_pdf_id)references pdf(pdf_id),
constraint book_type_fk foreign key (book_type_id)references book_type(type_id),
constraint gen_id_fk foreign key (genre_id)references genre_type(genre_id),
constraint lang_id_fk foreign key(written_in_language_id)references
all_language(language_id),
writer_id number(30,0) constraint writer references writers(writer_id))

create table is_a_translated_books(


book_id number(30,0) constraint id_book_fk references books(book_id),
translated_to_lang number(30,0) constraint translated_to_lang references
all_language(language_id),
translator_id number(30,0),
constraint pk_book_id_translated primary key(book_id)

create table translated_book(


translator_id number(30,0),
language_id number(30,0),
translated_bookID number(30,0),
constraint tr_id foreign key (translator_id)references translator(translator_id),
constraint tr_book_id foreign key (translated_bookID)references books(book_id),
constraint lang_id foreign key (language_id)references all_language(language_id),
constraint trans_books_pk primary key (translated_bookID,translator_id))

create table printed_books(


printed_book number(30) constraint printed_book_id references books(book_id) ,
printing_id number(30) constraint printed_id references printed(print_id)
constraint printed_book_pk primary key
)

create table sales(


sale_id number(30) ,
book_sale_price number(6,3),
sale_date date,
sale_discount number(3,0),
sale_count number(3),
constraint id_sale primary key(sale_id)
)

create table saled_books(


saled_book number(30) constraint saled_book_id references sales(sale_id)
constraint saled_book_id_pk primary key ,
print_id number(30) constraint print_id references printed_books(printing_id)
)

CREATE SEQUENCE seq_book_id


START WITH 1
INCREMENT BY 1
CACHE 10;

insert into book_type(type_id,type) values (seq_btypye_id.nextval,'‫)'ڕۆمان‬

insert into genre_type(genre_id,genre) values (seq_genere_id.nextval,'historical')

insert into genre_type(genre_id,genre) values (seq_genere_id.nextval,'‫)'مێژویی‬

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy