Most voted "database" questions
A database (its abbreviation is BD, DB, database) is an organized collection of data typically used to model certain situations. Use this tag if you have questions about designing a database. If this is a specific database management system, like Mysql, for example, use this tag instead.
Learn more…3,414 questions
Sort by count of
-
75
votes4
answers10585
viewsWhat is database normalization?
I was talking to some programmer friends when I heard the term "database normalization". Although I’ve heard that term a few times before, I couldn’t understand what it was about. Some doubts have…
-
66
votes7
answers11287
viewsIs it wrong to write byte of images into the database?
When should I make this recording directly at the bank? What situations? I know I can record in the bank the image path.
-
65
votes6
answers66144
viewsType of the CPF or CNPJ field in the VARCHAR or INT database?
What type of CPF or CNPJ field in the database VARCHAR or INT? I’ve seen some posts suggesting using INT to optimize performance in the event of JOINand filters. If you have 0 the left is only…
-
60
votes7
answers8794
viewsHow to Convert Mysql Database?
In the development of a web portal, using the git we made the control of everything that was changed at code level in the approval environment and with the Jenkins We moved the site to the…
-
60
votes8
answers16426
viewsWhy is using "SELECT * FROM table" bad?
It is often said to take all columns of a table through the command SELECT * FROM tabela is a bad practice. Any recommendation without explanation is not helpful. So... If it is bad practice, there…
-
54
votes2
answers6578
viewsBusiness Rules in the Database - what are the advantages and disadvantages?
Maybe I join a team to develop a new project. The leader has already made some decisions. Among them, that "business rules will be in the database". In "procedures" and "views", "triggers", etc..…
-
50
votes5
answers2269
viewsIs Nosql as troublesome as it seems?
I’ve been reading about Nosql lately, because the first impression I had about the technology was good. I did tests with Mongodb specifically and found it very practical and much easier than…
-
50
votes4
answers82876
viewsNot IN or Not EXISTS which to use?
I’ve seen some answers here with the use Not In and some with the use of Not Exists to answer the same question. I don’t know the difference between the two and would like to know about: Which of…
-
50
votes5
answers60507
viewsDISTINCT and GROUP BY, what is the difference between the two statements?
DISTINCT The SELECT DISTINCT statement is used to return only values distinct (different). Within a table, a column usually contains many values duplicated; and sometimes you just want to list the…
-
48
votes6
answers7903
viewsWhen should we allow a column of a table from a database to accept NULL?
This is a conceptual question that always creates confusion when deciding whether or not a column should accept NULL. There’s a current that considers the use of NULL to be an error and that an…
-
48
votes0
answers1178
viewsWhy are cost estimates in Postgresql so wrong?
Could someone help me understand why Postgresql missed several cost estimates in an experiment I did. I’m doing an experiment with 22 darlings of Benchmark TPCH[1], to verify index performance in…
-
47
votes1
answer5885
viewsHow to choose between Nosql and SQL?
Nosql databases are there, and one question I always have when starting a project is what criteria to choose between a relational database or not. How to evaluate my project to know the best option…
-
43
votes1
answer2932
viewsIs using PDO the safest way to connect to a PHP BD?
I’m a beginner in PHP and would like to know if PDO(PHP Data Objects) is the safest way to connect to a database? I also need an example of how to make this connection and enter/select data.
-
42
votes3
answers6498
viewsHow to model a tree data structure using a relational database?
How to appropriately and efficiently define naturally organized tree-based data in relational databases, considering the physical implications of this? That is, organize in a way that minimizes the…
-
41
votes2
answers33649
viewsWhat are SQL views? What are the advantages and disadvantages of using?
From my research I learned that views in SQL, are like virtual tables results of stored searches of frequent access. To W3S defines essentially as: virtual table. It has to be said that views are…
-
40
votes9
answers10435
viewsMy city zip code, where can I find open, updated and reliable source?
The Postal Address Code, CEP (or ZIP code) the addresses of a city guarantee greater reliability to address data and to geolocation resolution by address... Remembering that address is not only…
-
37
votes4
answers13910
viewsWhat is the best way to represent an Address?
When modeling addresses in an application, naively followed the standard form when representing in the BD (i.e. separate tables for country, state, city, neighborhood etc. - joins everywhere), and…
-
37
votes2
answers20576
viewsWhat are the differences between Myisam and Innodb?
What are the main differences between Engines MyISAM and InnoDB and what is the most appropriate situation for the use of each? I know that MyISAM can’t stand it FOREIGN KEY but supports FULLTEXT,…
-
37
votes3
answers2737
viewsHow to integrate microservices?
The idea of microservices is good. But I don’t really understand how to solve certain problems. Maybe the problem is how it is "sold". I don’t see much to say when to use it or when to avoid it. It…
database software-architecture transactions microservices acidasked 6 years, 9 months ago Maniero 444,682 -
36
votes2
answers25876
viewsWhat are the advantages and disadvantages of using indexes in databases?
What are the advantages and disadvantages of using indexes in databases?
-
34
votes3
answers8960
viewsWhen is it interesting to denormalize the database?
Is there any situation where having the database denormalized is more interesting than having it normalized? For example Normalized Pessoas Cidades | nome | cidade_id | | id | nome |…
-
33
votes8
answers48170
viewsHow to calculate a person’s age in SQL Server?
Suppose the table Pessoa and the countryside DataNascimento. In an SQL query, what is the best way to calculate a person’s age in integer format in the T-SQL language of SQL Server?…
-
33
votes4
answers5507
viewsWhy are NULL values not selected?
When making a select, I noticed that the data with field NULL are not recovered using the operator<>. Why does this happen? NULL is equal to a char N? See that in the query below only the…
-
33
votes4
answers2243
viewsAlternative to CPF (Foreign Users)
I have a site where we control users by number of CPF, I believe it is the best way because it is a given single, that everyone knows and is checavel. However the client now has foreign users who do…
-
32
votes2
answers6682
viewsWhat would be the way to validate the CPF checker digits in a DB using only a SELECT?
Finding information on how to calculate the CPF check digits is not difficult. Any Google search gives numerous results. Most are reliable and even have a well respected source which is the entry on…
-
31
votes5
answers12535
viewsWhy is Varchar(255) widely used?
Why in various databases, say to set the size as varchar(255)? For example, in a field email why put varchar(255)? It would not be better (in question of storage and processing speed) to put…
-
30
votes1
answer46121
viewsWhat is a DTO?
I’ve been dealing with Java for a little while and I always hear the expression DTO related to pulling something from a bank, but I never really understood what it is. Is it just a name to reference…
-
30
votes5
answers7016
viewsHow to delete all duplicates except one?
I have a table that has duplicate records. They shouldn’t be duplicated. Some records duplicated two, five and even thirty times by accident. I need to remove these duplicate records, but I need to…
-
28
votes7
answers33990
viewsHow do SELECT all fields except a few?
It is known (and has been asked) which should be avoided SELECT * in some cases in bank queries. But let’s imagine that I have a table with 50 columns, and I want to select 40 of them. Just the fact…
-
28
votes1
answer3003
viewsHow does the Repository standard work?
I was doing a study on a framework in PHP called Symfony. When I was studying about the database research, I realized that there are some differences in relation to the searches, as in frameworks as…
database oop pattern-design software-engineering repositoryasked 8 years, 11 months ago Wallace Maxters 102,340 -
26
votes2
answers2693
viewsWhat is the difference between charset and collation in a database?
Every time I create a database, I always come across these definitions and I don’t really know the difference. I understand what it is charset, but not collation.
-
26
votes1
answer48265
viewsWhat character encoding (Collation) should I use in Mysql?
What is the most appropriate character encoding (Collation) for a Mysql database that will store Portuguese language data?
-
24
votes4
answers4178
viewsWhat is the difference between joining tables by JOIN and WHERE?
What is the difference between joining tables by JOIN or by WHERE? Examples: SELECT * FROM clientes c JOIN enderecos e ON c.id = e.id_cliente; SELECT * FROM clientes c, enderecos e WHERE c.id =…
-
24
votes2
answers6702
viewsIs the ZIP code a unique ID in Brazil?
I own the official CEP base in Brazil, e-DNE, sold by the post office. I need to create a new bank from it, and would like to know if I can use the ZIP code value as my DB’s unique identifier. As…
-
24
votes1
answer5461
viewsWhich encoding to choose for a database?
When we create a new base (whether it is in Mysql, Postgresql, Oracle, Sqlserver or other) we can choose which one encoding of that bank, for example, UTF-8 or Latin-1. Is there any recommendation…
-
24
votes1
answer2772
viewsAre unnecessary bank ratings a problem?
Indexes are usually added to improve the performance of queries. However, it is not usually recommended to add indexes in all columns, only where the need is identified. Why this recommendation?…
-
24
votes3
answers13327
viewsWhat is the difference between vertical and horizontal scaling?
I’ve recently seen some things about cloud, BD’s, etc. In some of these subjects I see quite the term scheduling. Faced with this theme I have the following doubts: The difference between vertical…
-
24
votes2
answers67807
viewsWhat are the acronyms DDL, DML, DQL, DTL and DCL?
I was setting up a permissions structure in the bank (GRANT, REVOKE), when I found this article and found it interesting to share, even to have here at Sopt. Original issue What is DCL? Source…
databaseasked 6 years, 11 months ago Guilherme Lautert 15,097 -
24
votes4
answers453
viewsTable change constraint with subquery
To documentation mysql says: you cannot Modify a table and select from the same table in a subquery you cannot change a table by selecting data from it in a subquery This applies to DELETE, UPDATE…
-
23
votes3
answers1636
viewsHow to create a conditional index in Mysql?
How to create an index filtered by a specific data range? As far as I know, it is impossible to do this directly in Mysql. In some other database systems, there is usually a WHERE clause for this…
-
23
votes1
answer2914
viewsIndexes in Mysql queries
Using indexes in mysql queries really makes the result come quickly for some large queries or tables. For example in the query below: SELECT * FROM table WHERE status = 1; For a table with 1 million…
-
23
votes2
answers4023
viewsCan it be considered a bad modeling practice to store all people (customers, employees, suppliers) in the same table?
I am trying to design a database for a small project but I am having difficulties regarding the normalization of the tables of persons (physical and legal): Client Supplier Professional I thought…
-
23
votes2
answers5722
viewsWhat’s wrong with the N+1?
Whenever we work with some ORM, it is common to fall into the problem of darlings N+1. It’s something about performance, called even antipattern. But what is really this problem, why it happens,…
-
22
votes2
answers19395
viewsWhat’s the difference between varchar and nvarchar?
What’s the difference between using data types varchar and nvarchar? nvarchar exists in every SQL database? Is there any significant difference in performance between the two? There is a criterion…
database sql-server string typing character-encodingasked 7 years, 5 months ago UzumakiArtanis 9,534 -
21
votes3
answers17170
viewsHow to generate numerical sequences in SQL without creating tables?
Reading the question How to set to zero or null in an SQL query of a date range, for those whose value does not exist? I remembered a similar problem I have. Usually when I need those sequences that…
-
21
votes3
answers23896
viewsDifference between type text and type varchar in SQL Server
What’s the difference of using text instead of type varchar to store information in the database? Is there a performance problem? Because I have a table in the database that has a column text and…
-
21
votes3
answers1556
viewsSQL in the code or in the database?
I’m having a big doubt about where I should put mine query SQL, whether in code or bank. Currently I have a Procedure which is mounted according to the parameters I have, ie, filtros. Procedure…
-
21
votes2
answers11055
viewsWhat is the advantage of using the ENUM type?
When I should use the guy ENUM because even today where I saw this guy being used he could be replaced by VARCHAR or even for a simple CHAR, I can’t see a case where in it it really becomes…
-
21
votes1
answer6034
viewsWhat is the storage limit for Sqlite?
A new demand for the application of the company where I work, I need to store more than 100k of records in different tables, I’m worried if the Sqlite will withstand such demand, my question is:…
-
21
votes3
answers2676
viewsWhen to use SET and SELECT?
I know that as in virtually all issues related to "either" there must be situations where it is best to use SET or SELECT, in a Procedure (for example). At work we always wear the same SELECT, even…