IscanderChe
IscanderCheAug. 29, 2019, 5:02 a.m.

DBComponents project. Part 1. Requirements for the project and database

Project requirements

The project implements a database of IT components. Three categories are planned so far: monitors, medical printers, system units. The functionality of the database also includes the ability to create new categories.

The project should consist of two functional parts - the admin panel and the user panel.


Admin panel should contain the following views and tools:

  • list of categories and the button of the command "New category";
  • list of category parameters and buttons of commands "New parameter" and "Edit parameter";
  • list of category components and buttons for commands "New component" and "Edit component".

On button click:

  • "New Category" dialog box for creating a new category of components should be called, containing the lines for entering the name of the category in the view (visible name) and the name of the category for the database (only Latin plus an underscore);
  • "New parameter" dialog box for creating a new parameter should be called, containing the lines for entering the name of the parameter in the view (visible name) and the name of the parameter for the database (only Latin plus underscore), the "Sublist Title" checkbox to indicate that the parameter is dummy and is not subject to filling in the database, and the drop-down list "Position in the list" with position numbers. By default, the position number in the list follows the last existing parameter;
  • "Edit parameter" dialog box for editing a parameter should be called, containing a line for entering the parameter name in the view with a previously entered value;
  • "New component" dialog box for creating a new component should be called, containing input lines for previously created component parameters. If the parameter is not filled in, then in the database this parameter should be recorded as "n / a" (no data);
  • "Edit component" dialog box for editing the component should be called, containing lines for entering the parameters of the component with previously entered values. If the parameter is recorded in the database as "n/a", the parameter entry string must be empty.

The User Panel should contain the following views and tools:

  • list of categories;
  • a block of filters for components, consisting of input lines and/or drop-down lists of the main parameters (should be defined programmatically, at the code level);
  • a list of components for the selected category that satisfies the filter conditions;
  • list of parameters for the selected component;
  • the button of the "Export to Excel" command, by clicking on which the list of parameters and parameter values for the selected component is exported to an Excel table.

Database requirements

Regarding this part, I have doubts about the correctness of the solution, and therefore I ask the respected community to confirm my choice or suggest another solution. Thank you in advance.

The database must use SQLite DBMS and contain the following tables:

  • table of component categories components_category with fields id , name , view_name ;
  • tables of component parameters by the number of categories parameters_<name> (where name is the content of the corresponding field of the table of component categories components_category ), with fields id , name , view_position , view_name , header ;
  • tables of values of component parameters by the number of categories values_<name> (where name is the content of the corresponding field of the table of component categories components_category ), with fields id , <name1> , <name2> , … <nameN> (where name1 , name2 , … nameN are the contents of the corresponding name field of the parameter table components parameters_<name> ).
We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.

Do you like it? Share on social networks!

ИП
  • Aug. 30, 2019, 1:34 a.m.

Я бы сделал базу в таком виде:

CREATE TABLE "components" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"name" TEXT
);

CREATE UNIQUE INDEX "index"
ON "components" ("name" ASC);

CREATE TABLE "parameters" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"components_id" INTEGER,
"name" TEXT NOT NULL,
FOREIGN KEY ("components_id") REFERENCES "components" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT
);

CREATE TABLE "values" (
"id" INTEGER NOT NULL,
"vparameter_id" INTEGER,
"name" TEXT,
PRIMARY KEY ("id" ASC),
FOREIGN KEY ("vparameter_id") REFERENCES "parameters" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT
);
Не совсем понятно назначение поля view_position, но если сильно нужно, то его можно добавить в таблицу "parameters"
Если есть такая необходимость, то можно "ON DELETE RESTRICT" заменить на "ON DELETE CASCADE", тогда при удалении строки из "components" сразу удалятся соответствующие parameters и values

IscanderChe
  • Aug. 30, 2019, 2:41 a.m.

CREATE UNIQUE INDEX "index"
ON "components" ("name" ASC);

Вот эти строки поясните, для чего они.

Не совсем понятно назначение поля view_position

Это поле нужно для хранения позиции параметра в представлении, поскольку может получиться так, что добавили ещё один параметр, но он должен располагаться выше ранее введённых параметров.

при удалении строки из "components"

Т.е. то, что написано после FOREIGN KEY, относится к удалению из "components"? На данный момент удаления из "components" как такового не предполагается.

ИП
  • Aug. 30, 2019, 3:12 a.m.
  • (edited)

CREATE UNIQUE INDEX "index"
ON "components" ("name" ASC);
индекс на поле name, дополнительно делает поле name уникальным

| Т.е. то, что написано после FOREIGN KEY, относится к удалению из "components"? На данный момент удаления из "components" как такового не предполагается.
Так и есть, помимо этого FOREIGN KEY не дает содать parameters со значением components_id если нет соответствующего значения id в components. FOREIGN KEY обеспечивает целостность данных между 2 таблицами при добавлении и удалении данных

parameters с полем view_position будет выглядеть так:
CREATE TABLE "parameters" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"components_id" INTEGER,
"name" TEXT NOT NULL,
"view_position" INTEGER,
CONSTRAINT "fkey0" FOREIGN KEY ("components_id") REFERENCES "components" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT
);

IscanderChe
  • Aug. 30, 2019, 3:40 a.m.

CONSTRAINT "fkey0"

А вот это для чего?

Comments

Only authorized users can post comments.
Please, Log in or Sign up
AD

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:50points,
  • Rating points-4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:80points,
  • Rating points4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:20points,
  • Rating points-10
Last comments
i
innorwallNov. 14, 2024, 8:09 p.m.
Qt/C++ - Tutorial 068. Hello World using the CMAKE build system in CLion ditropan pristiq dosing With the Yankees leading, 4 3, Rivera jogged in from the bullpen to a standing ovation as he prepared for his final appearance in Chicago buy priligy pakistan
i
innorwallNov. 14, 2024, 3:05 p.m.
EVILEG-CORE. Using Google reCAPTCHA 2001; 98 29 34 priligy buy
i
innorwallNov. 14, 2024, 3 p.m.
PyQt5 - Lesson 007. Works with QML QtQuick (Signals and slots) priligy 30mg Am J Obstet Gynecol 171 1488 505
i
innorwallNov. 14, 2024, 1:54 p.m.
Django - Tutorial 003. Model, Template, View on Django Hair follicles are believed to produce approximately 20 individual hair shafts over the life of the follicle as the follicle progresses through cycles of hair production, shedding ejection, invo…
i
innorwallNov. 14, 2024, 10:03 a.m.
How to make game using Qt - Lesson 3. Interaction with other objects what is priligy tablets What happens during the LASIK surgery process
Now discuss on the forum
i
innorwallNov. 14, 2024, 2:39 p.m.
добавить qlineseries в функции priligy amazon canada 93 GREB1 protein GREB1 AB011147 6
i
innorwallNov. 11, 2024, 9:55 p.m.
Всё ещё разбираюсь с кешем. priligy walgreens levitra dulcolax carbs The third ring was found to be made up of ultra relativistic electrons, which are also present in both the outer and inner rings
9
9AnonimOct. 25, 2024, 7:10 p.m.
Машина тьюринга // Начальное состояние 0 0, ,<,1 // Переход в состояние 1 при пустом символе 0,0,>,0 // Остаемся в состоянии 0, двигаясь вправо при встрече 0 0,1,>…

Follow us in social networks