Normalisation - SQL - 3NF

折月煮酒 提交于 2019-12-24 15:59:38

问题


I am designing a SQL database that needs to be a five-table database to meet Air-Crewe’s requirements. I have the following so far:

I have this for UNF:

CrewID, Crew Type, Title, Forename, Surname, Gender, CAALicenceNum, FlightID, FlightNum, IATADep, IARAArr, Date, SchDep,SchArr, Comments, A/CType, A/CReg, A/CManuf

I have this for 1NF:

TBLCrew(CrewID[PrimaryKey], CrewType, CrewTitle, Forename, Surname, gender, CAALicenceNum, FlightID*)

TBLFlight(FlightID[PrimaryKey], FlightNumber, IATADep, IATAArr, Date, SchArr, comments, A/CType, A/CReg, A/CManuf)

I have this for 2NF:

TBLCrew(CrewID[PrimaryKey], CrewType, CreweTitle, Forename, Surname, gender, CAALicenceNum)

TBLFlight(FlightID[PrimaryKey], FlightNum, IATADep, IATAArr, Date, SchArr, comments, A/CType, A/CReg, A/CManuf)

TBLCrewFlight(CreweID[composite/compoundKey], FlightID[composite/compoundKey])

The 3NF needs to be be separated into five tables but I don't know how to achive this - can anyone please help me out? Or correct me if I have made a mistake in the normalisation above (I am new to normalisation as you probably can tell)


回答1:


Accepted answer can have more Aircrafts for a flight, I do not think that is correct.

TBLCrew(CrewID[PrimaryKey], CrewType, CreweTitle, Forename, Surname, gender, CAALicenceNum)

TBLFlight(FlightNum[PrimaryKey], IATADep, IATAArr, Date, SchArr, A/CReg[composite/compoundKey])

TBLCrewFlight(CreweID[composite/compoundKey], FlightNum[composite/compoundKey], Comments)

Aircraft(A/CReg[PrimaryKey], A/CType[composite/compoundKey])

TBL_A/CType(A/CType[PrimaryKey], A/C Manuf)



回答2:


First of all - I am unsure even of the 1st form. Comments implies multiple instances of a comment, therefore it probably isn't atomic and I would make a table for them too. It would have three attributes - comment_ID, comment, FlightID.

In the 3rd form every non-prime attribute of the table is non-transitively dependent on every superkey of the table. So in layman's terms if you logically identify attributes which are dependent on another non-key attribute, you need to transform them into another table.

If gender is dependent on the forename is arguable. Other decompositions are somewhat difficult, since I don't have the descriptions of the columns (not entirely sure what they represent).

However here I present some of my speculations:

  • CrewTitle probably depends on the gender - bam new table
  • Departures and arrivals depend on the Flight number - bam new table
  • A/C types and manufacturers probably depend on the A/C Reg - bam new table

However, you should have better understanding of the individual columns, and therefore you should make these decisions by yourself. These examples should help you to understand the 3rd form concept.




回答3:


I think you're actually almost there. I'd split the aircraft information into its own table

Aircraft(CraftId[PimaryKey], A/CType, A/C Rep, A/C Manuf)

And then assign aircraft to the flight

AircraftFlight(CraftId, FlightId) [Composite Key]


来源:https://stackoverflow.com/questions/32934319/normalisation-sql-3nf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!