I have to migrate my custom system to typo3 version 6.2 but I did not find any database diagram(design/schema) of typo3. Would be great if someone can help. Thank you.
In a TYPO3 installation without extensions, there are not many tables that will interest you. Interesting tables are
pages and pages_language_overlay: Pages and their translations.
tt_content: Content, translations are in the same table.
sys_language: Define available languages. For pages with only a default language it can stay empty.
sys_domain: Define Domains under which a site is available. For single domain installations it can be left empty.
sys_file_reference: References to files, which are stored in table sys_files. The table sys_files will be automatically filled when you put files into the fileadmin folder.
fe_users and fe_groups: Frontend users and groups.
The other tables are either caching tables (names start with cf_) or are mostly used internally (most tables having names starting with sys_).
In some of the tables, especially in pages and tt_content, there are deprecated fields.
The usage of some fields depends on the actual TYPO3 setup. For example, the text of a content element from tt_content could be stored in the field bodytext, or in the field pi_flexform. So the question how to import your data depends on your setup.
For further information have a look at the official docs: https://docs.typo3.org/typo3cms/CoreApiReference/latest/ApiOverview/Database/DatabaseStructure/Index.html
I don't have a diagram either, but this note is too long for a comment:
Most M:N relationships (e.g. users & groups) are handled with foreign key attributes stored as comma-separated entries inside table cells, inside rows of the parent table. Of course, this nonatomic way of storing data violates first-normal form of database-table design.
However, some newer extensions do rely on bridge tables. In typo3, this is called an M:M relation, and some tables have a naming corresponding convention, e.g. tt_news_cat_mm, linking news-messages with news-categories.
Related
Since TYPO3 uses doctrine it is possible to use tables from multiple databases in one instance (with some restrictions like no joins).
But what is possible at all?
At the moment I need two external tables for an extension and instead of using them directly I import them to work locally as usual. But the importing has some draw backs.
Draw backs I can accept:
the data is not live (changes to the external tables are imported later)
the data is read only (changes are done externally anyway)
For importing I use ext:external_import but there are some problems as not all data can be imported in a single run, and then there are errors (e.g. there are reports about duplicate keys, alas there are no duplicate keys in the external tables)
On the other hand I doubt I can use the external tables directly as they have not the usual TYPO3 structure (fields: 'uid', 'pid', 'tstamp', ...). (Maybe they can be mapped in a view?) (of course in the tables I import the data into these fields exist)
Also external changes may be unnoticed and cached content does not reflect current data. In my case that would be a minor problem, as we currently already have no 'live' data, but this needs to be cleaned regularly for cache and for the search index (solr).
What are possible solutions? ? (do they depend on the TYPO3 version?)
What are your experiences?
EDIT:
While trying to realize it considering the given answers more doubts appear:
the tables are readonly (as they are changed from outside):
How do I declare it to TYPO3?
the tables does not follow the usual name rules, especially one table is named sys_category which in this way conflicts with the TYPO3 table sys_category.
Can I build a mapping inside of TYPO3?
Can I build a view from TYPO3 for renaming tables and fields?
like:
CREATE View tx_myext_category
SELECT id as uid, name as title, ...
FROM databasename.sys_category;
Yes, you can fetch data directly from other databases/tables. Of course it highly depends on the usecases and the data you get:
It works fine to read/write data by using the queryBuilder and all the APIs you know from https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Database/Index.html like ConnectionPool, QueryBuilder
If you want to show the data in the formengine, e.g. list module, you will need to have the minimum columns like uid, pid and a valid TCA as well.
From my experience, the mapping mechanism only works if the external table has a almost similar structure as TYPO3 tables. You need at least a uid field on the external side. This cannot be mapped! A missing pid field could be managed with on the TYPO3 side, also crdate or tstamp if needed. Just fill the local data array with the values TYPO3 needs.
Problems arise if you have relations to deal with. Many external systems have other ways to handle relations. You could run into many problems if you try to rely only on the mapping mechanism.
Other problems are fields with date format. Most external tables in the MS world use another format as the unixtime.
If you run into problems with the mapping mechanism you can switch to the TYPO3 queryBuilder. This is a powerful fallback. I experienced problems only with a special type of JOIN statements.
But with the TYPO3 queryBuilder you are on your own. You place instances of the queryBuilder code in the repository and add your model code as usual: thus you can continue to work with Fluid in the frontend as you are used to.
ANSWER TO EDIT:
With the TYPO3 queryBuilder readonly tables aren't a problem. Just don't implement the setter classes in your models.
With TYPO3 queryBuilder you can call any external table with any name. You have full control over the output data in your repository because the mapping is handled inside of it.
As far as I know, there is no way to create SQL views in TYPO3 up to v9, neither with the DBAL mapping mechanism nor with the TYPO3. queryBuilder.
I have PostgreSQL DB behind a Prisma 1.34 and Graphql-yoga.
There few linked tables(Prisma types/entities) that represent templates. These templates model hierarchical structure with parents and children that can be used in the creation of the actual entities that then user going to work with (edit these types, change text, description and properties).
The thing I need to do is to copy these templates into the different tables.
I was thinking to do it through the mutation. Just can wrap my head around the correct or right way of doing it. I can get the id of a parent entity from the user and then either query it from DB with all nested entities and then create it and all nested one. Is it the right way of doing it? or Prisma has something built-in or are the different solution (best practice) to do such things in Grapql setting?
I would like to create an extension like tt_news , so i need to connect with my own tables .
So how to write data fetching and insertion to the custom table
In general, creating the extension from the scratch doesn't make a sense especially when you're learning.
Old school
For 'old school' extension it's the best way to install Extension Kickstarter.
It will help you to create tables, all required structure etc. Also will allow you to extend existing tables (ie. you can use it to modify tt_news tables and add custom filds without touching the tt_news' sources)
You should choose this way especially when you want to impact with some well-known extension written the same way.
All methods for working with DB can be found in the API
MVC - Extbase
If you're more familiar with MVC it would be better to use Extension Builder
It's the funnier way and allows to create extension faster, however it's less documented and more abstract.
It has also built-in modeler for creating your DB tables (Models) and creates set of default actions for the listing, displaying, modifying and removing records from your table. (with the bit of experience simplified version of the tt_news ca be created in few hours)
I generally prefer extbase and fluid for my new exts, esspecialy as it's some kind of preparation to work in the future with flow3, but you need consider which points are more important to you.
I want to create a Typo3 plugin that can be used as a content type on pages (i.e. FE plugin), without any user input. The plugin would generate content from additional tables in the typo3 database. The content for these tables is inserted outside of typo3.
From what I understand, I have to do the following:
ext_tables.php: The TCA configuration is used for configuring how fields can be edited in the Back End. Since the user must not enter any data, I will not need this
ext_tables.sql: Write the CREATE statements for my tables. This will update the typo3 database and keep it in synch with this definition on updates
Are there any other configuration files I have to edit?
What about views? Does Typo3 understand CREATE VIEW statements in the ext_table.sql?
Thanks for any hints!
if you don't need to create a table for your extension you don't need to worry about linking them up on ext_tables.php. I would just write your code into the pi1.php file, querying the desired table and outputting the result.
The file where your code sits is usually on
pi1/class.tx_myextension_pi1.php
Our company is in the middle of evaluating a couple of different ORMs and we are currently looking at the EF4 side of things.
I have a small question that I hope someone here can answer...
In our generated EntityDataModel.Designer.cs file all our Entity classes (and the properties within them) have a ///summary with the sentence "No Metadata Documentation available".
Is there any way to have these picked up from the Description Property on the columns from SQL Server?
I can see there is a documentation property within the edmx file but they are all blank.
Obviously its not a deal breaker in our decision - but it would be nice.
Thanks for any advice
Aaron.
Yes, documentation properties are blank in EDMX because you must fill them yourselves. EF doesn't load columns descriptions defined in SQL Server.
These columns descriptions are stored in sys.extended_properties and have MS_Description as a name. Theoretically you can modify T4 template (EFv4) to load descriptions for columns and create comments but it would be a lot of work to do. You will have to:
for each scalar property you will have to search metadata to get column and table name and query DB to get a description
That is a lot of work and having T4 template opening connection to database is very uncommon.