Forum > Databases

setup of database and tables (newbee question)

(1/3) > >>

Arnoldg:
Hello,

I'm trying to setup a new database with tables and that kind off stuff.

now is my question, i have a lot of different tables with the same kind of information.
example:
table1=firecompany:
ID
Name
Adres
Postal
City
Certification number

table2:manufactor:
ID
Name
Adres
Postal
City

table3:subcontractor
ID
Name
Adres
Postal
City

What i think the best way to do this is to make 4 tables like this:

table1: information
ID_information
Name
Adres
Postal
City

table2: firecompany
ID
ID_information
Certification number

table3 manufactor:
ID
ID_information

table4 subcontractor:
ID
ID_information


is this the right way if knowing that a manufactor an also be a subcontractor.
If this is the right way how to connect the tables to gether and reprecent the data in lazarus IDE

egsuh:
Relational database is a separate area from Lazarus. You need to study some basic stuff on relational database, and SQL statements. Then try to write applications dealing with databases with Lazarus.

devEric69:
Hello @Arnoldg,

First, choose your database:
- is it for a desktop-only program (locking the full tables like with Paradox or dBase)?
- is it with several clients and a centralized server (and possibility to lock only some records of each table like with mariaDB or fireBird), ...?

Then study the choosen SQL engine (primary versus foreign keys, how to make relationships between tables), then choose a SQL manager in order to make the SQL statements \ DDL queries, and to create your database. Only then, you will code with Lazarus (and its components like TDatamodule, TConnexion, TDataset, TQuery, ..., TDataSource, TDBedit, TDBGrid, ..., TForm).

Here are some SQL managers:
- DB browser for SQLite (SQLite)
- FlameRobin or RedExpert (Firebird)
- MyDbfStudio (dBase)
- PhpMyAdmin (mySQL\mariaBD)
- the project .../lazarus/tools/lazdatadesktop (a little bit of everything, like the "Database Desktop" of Delphi)

Zvoni:
What the others said not withstanding:
I'd rather go like this

Table1 - tbl_addresses (or whatever name)
ID
Category_ID
Name
Address
PostalCode
City
WhateverOtherFields

Table2 - tbl_category
ID
Description

Description in table 2 would be like "FireCompany" etc.

af0815:
It is no Problem to create tables at runtime, but it can differ on the DB you use. The simplest way is to do it on a SQL based DB.

Navigation

[0] Message Index

[#] Next page

Go to full version