Database Primary Keys and Validation -


'ello, I am a student in college, I am studying computing. I am currently working my course (which insists on creating a database) and I was hoping that you can clear some things for me Side-Note: Programming is not specific.

1) Can you use wire as a primary key i.e username? 2) Should the primary key be "id" in their name? 3) If you use the name as the primary key, will you be able to use the verification technique to ensure that each name is unique?

I have done most of my research at present that I can use the names as a primary key and verification to make sure that they are unique, because an example database that we researched The same principle was made earlier, however, my teacher (a new teacher) is telling me that I need to do my work again and I try to get out of doing everything again And am I, because I have consulted my learning resources and can not find any reason for not being able to use to use integer primary key or verification for any reason.

1) You can create a string column primary key, but as already mentioned, It is not wise. Value, which is something that could invalidate the key referred to, can change, and usually need to destroy the data line and insert again with a new key to the storage efficient key There is also no possibility. A 64-bit identifier (normal case) 8 is going to use less space than any name compared to ASCII characters. Is going to make comparisons between any query keys that link the primary key, and they are going to be the most competent to be aligned in the hardware, which is about 64-bit

2) naming convention so Can be powerful, so to include an indicator of the column name it shows that this primary key is intelligent. I personally dislike the use of ID for this, because I had been so used to all database release actual ID field (such as employee ID Y / N) and does it cause confusion I as the primary key name I like the PK_tablename (and the FK_tablename for the foreign key which is linked to it) but with any standard name it is optional to see the SQL point.

3) You can use verification techniques to ensure specificity before the inclusion, but it is another argument against using anything, but the nonsensical numbers in the form of keys. Issues of concurrency with the key is easy to ignore if two processes try to insert the same name at the same time, and each individual checks before being (uniqueness), then you're in Dedloking or racing conditions Almost all databases offer a guarantee that the default key datatype (again, usually 64-bit) can be generated atomically Awareness that is it does not matter that you insert a row and make sure that every row has a unique ID if you wrap your recognition transactions, forced to sort the concurrent entry of the same key , You can delete your performance or remove other deadlock issues.

Your professor is right to go with the default key datatype, even if you do not have it


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -