SQL Server 2008 - Table - Clarifications -
I am new to SQL Server 2008 database development
Here I have a master table called 'Student' And there is a child table called 'Address'. The common pillar between these tables is 'student id'.
My suspicion is:
-
Do we make 'address' table and primary key? Is it mandatory? (I will not use this 'Address ID' in any of my reports)
-
Should the primary key column be in any table?
Will you help me on these?
Would you please see the best link / tutorial for SQL Server 2008 database design practices (if you know) that includes naming conventions, best practices, SQL optimization, etc.
1) Yes, ADDRESS_ID column to ADDRESS Table is a good idea.
But STUDENT_ID is not a good idea as a foreign key in the ADDRESS table. This means that an address record can only be linked to one student. Students can be living in the room, so they will have the same address. Which is a good idea to have the ADDRESS_ID column as a priority, because it will indicate a unique address record.
instead of STUDENT_ID in the column, I have ADDRESS column in the STUDENT and ADDRESS tables There will be a corrupted / xref / lookup table between:
STUDENT_ADDRESSES_XREF
-
STUDENT_ID, pk, Code> Students -
EFFECTIVE_DATE, date, not blank -
EXPIRY_DATE, date, zero
ADDRESS_ID , pk, fk to ADDRESS table This uses an overall primary key, so that the student Only one combination of & amp; Address exists I add dates, when I really need to know, because a person can go back home / etc.
Most importantly, it closes the ADDRESS_ID column to allow the same address to be linked to many people.
2) Yes, defining the primary key is clearly necessary for any table.
In most databases, it also acts as an index - more efficient searching, it is always at the top of things like creating records is a unique entry ...
< / Div>
Comments
Post a Comment