in Education by
Academia has it that table names should be the singular of the entity that they store attributes of. I dislike any T-SQL that requires square brackets around names, but I have renamed a Users table to the singular, forever sentencing those using the table to sometimes have to use brackets. My gut feel is that it is more correct to stay with the singular, but my gut feel is also that brackets indicate undesirables like column names with spaces in them etc. Should I stay, or should I go? Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
Honestly speaking, stick to one convention whatever you have decided to use and apply that throughout your project. Use what feels the most comfortable for you. Want to learn SQL from basics! Here's the right video for you on SQL provided by Intellipaat: It’s mostly recommended to use SINGULAR. I personally believe we are naming a relation not a table. We are addressing the relationship between the user’s name, ID and their address, etc. It’s not difficult to understand that there’s only one relationship for user data. So, if we have described the user relation once, then we can use for many users. I’ll list out some important facts why we should really use SINGULAR instead of PLURAL: 1.It helps to avoid the confusion of English pluralization which can be tricky sometimes for non-fluent writers. Example: Person becomes people while activity becomes activities and data remains data, so it’s a bit confusing for a few users. 2.You can consider using the “set theory” when you are using singular names. In simple term, any instance in the set is nothing but a representative of the set. So, orange is an Orange set. It doesn’t matter how many apples are in the set. 3. If you see according to SQL statement point, it doesn’t feel natural to write a plural name for a query on a single item. Example: SELECT id, name, description FROM products product WHERE product.name = ‘foo’ AND product.description = ‘bar’ If you are dealing with more complex pluralization: SELECT id, name, description FROM activities activity WHERE activity.name = 'foo' AND activity.description = 'bar' Still, if you are concerned about writing the best-looking code that has proper English, then my advice would be to use plural names for the tables whereas, use a singular name for the corresponding entities. Ex: /** * @Person * * @ORM\Table(name="people") */ class Person { ... } The table people store all the instances of possible object person. Thus, when we are working with object then it makes sense to use this syntax: $person = new Person () and $personàsetName(“foo”). Apart from that, you can follow these tips: To separate words (no camelCase or no spaces), for ex: product_quantity. For the tables use short names. Don’t use ID, use id. As your PK (Primary Key), don’t use table name followed by “id”. Use the only id it’s more than enough. It’s easier to read customer_bills rather than cub. To be more descriptive while naming it as table name should represent its content.

Related questions

0 votes
    Just wondering if any of you guys use Count(1) over Count(*) and if there is a noticeable difference in ... SQL Server 2005.) Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I need to remove a highly referenced table in a SQL Server database. How can I get a list of all the ... of the management studio.) Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    How do I do a SELECT * INTO [temp table] FROM [stored procedure]? Not FROM [Table] and without defining [ ... not supply any columns. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    How can a column with a default value be added to an existing table in SQL Server 2000 / SQL Server 2005? Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    I have written an SQL script which runs fine when executed directly in SQL Management Studio. However, when entering ... are removed: Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have a user defined function in SQL called getBuisnessDays it takes @startdate and @enddate and returns the number of ... WHERE ... Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have a SQL column with a length of 6. Now want to take only the first char of that column. Is there any ... in SQL to do this? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I didn't see any similar questions asked on this topic, and I had to research this for something I'm working ... had the same question. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have a user defined function in SQL called getBuisnessDays it takes @startdate and @enddate and returns the number of ... WHERE ... Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    I have a SQL column with a length of 6. Now want to take only the first char of that column. Is there any ... in SQL to do this? Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    I didn't see any similar questions asked on this topic, and I had to research this for something I'm working ... had the same question. Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    I have seen SQL that uses both != and for not equal. What is the preferred syntax and why? I like !=, ... reminds me of Visual Basic. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    Both these joins will give me the same results: SELECT * FROM table JOIN otherTable ON table.ID = ... different SQL implementations? Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    SELECT GETDATE() Returns: 2008-09-22 15:24:13.790 I want that date part without the time part: 2008-09-22 00: ... How can I get that? Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    How do I perform an IF...THEN in an SQL SELECT statement? For example: SELECT IF(Obsolete = 'N' OR ... Saleable, * FROM Product Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
...