模式和表的MySQL命名约定为小写字母?

时间:2019-05-24 14:37:50

标签: mysql mysql-workbench

在MySQL Workbench 8.0中,我将表命名为using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using iTextSharp; using iTextSharp.text; using iTextSharp.text.pdf; using Font = iTextSharp.text.Font; namespace ConsoleApp1 { class Program { public static void AddPageNumber(string fileIn, string fileOut) { byte[] bytes = File.ReadAllBytes(fileIn); Font blackFont = FontFactory.GetFont("Arial", 12, iTextSharp.text.Font.NORMAL, BaseColor.BLACK); using (MemoryStream stream = new MemoryStream()) { PdfReader reader = new PdfReader(bytes); using (PdfStamper stamper = new PdfStamper(reader, stream)) { int pages = reader.NumberOfPages; for (int i = 1; i <= pages; i++) { //ColumnText.ShowTextAligned(stamper.GetUnderContent(i), Element.ALIGN_RIGHT, new Phrase(i.ToString(), blackFont), 568f, 15f, 0); ColumnText.ShowTextAligned(stamper.GetUnderContent(i), Element.ALIGN_RIGHT, new Phrase(String.Format("Page " +i+ " of " + pages.ToString())), 568f, 15f, 0); } } bytes = stream.ToArray(); } File.WriteAllBytes(fileOut, bytes); } static void Main(string[] args) { string inputPdfString = @"C:\Users\*************\Desktop\Doc1.pdf"; string outputResultString = @"C:\Users\************\Desktop\Doc2Out.pdf"; AddPageNumber(inputPdfString,outputResultString); Console.WriteLine("Finished!"); Console.Read(); } } }

但是它在创建后会自动在Smartphone Brand中命名,这很烦人,而且很难找到没有大写字母或空格字符的名称。

有人在MySQL中对模式和表有任何命名约定吗?

1 个答案:

答案 0 :(得分:1)

使用小写(a-z),数字(0-9)和下划线字符(_)作为表名。

此约定提供了最佳的可用性和可移植性。这在《 MySQL参考手册》中有记录:

https://dev.mysql.com/doc/refman/8.0/en/identifier-case-sensitivity.html

节选:

  

为避免此类差异引起的问题,最好采用一致的约定,例如始终使用小写名称创建和引用数据库和表。建议使用此约定,以实现最大的可移植性和易用性。


标识为“智能手机品牌”的实体可以实现为表名smartphone_brand


我倾向于遵循的另一种约定是用单数命名表。命名表格中的哪一行代表。为什么我将表命名为smartphone_brands

也请使用完整的单词,并避免使用缩写。另外,请避免使用对象类型标识符(例如tbl_smartphone_brandsmartphone_brand_table)为表名加上前缀/后缀。

-

当然可以遵循其他约定来产生成功的软件项目。我遵循的约定只是一种可能的模式。

作为行业专家,一旦我们遇到其他数据库标识符约定的重大问题(例如,从Windows到Linux的数据库应用程序的简单端口应该变成费力的工作),可以通过以下方法避免这种情况:遵循不同的约定,我们发现那些我们目前可能识别为次要烦恼的功能证明可以节省大量时间。

相关问题